Google as new provider (using Mopidy core), starting #266
This commit is contained in:
13
src/js/services/google/actions.js
Executable file
13
src/js/services/google/actions.js
Executable file
@ -0,0 +1,13 @@
|
||||
|
||||
export function set(data){
|
||||
return {
|
||||
type: 'GOOGLE_SET',
|
||||
data: data
|
||||
}
|
||||
}
|
||||
|
||||
export function getLibraryArtists(){
|
||||
return {
|
||||
'type': 'GOOGLE_GET_LIBRARY_ARTISTS'
|
||||
}
|
||||
}
|
||||
38
src/js/services/google/middleware.js
Executable file
38
src/js/services/google/middleware.js
Executable file
@ -0,0 +1,38 @@
|
||||
|
||||
import ReactGA from 'react-ga'
|
||||
|
||||
var helpers = require('../../helpers');
|
||||
var coreActions = require('../core/actions');
|
||||
var mopidyActions = require('../mopidy/actions');
|
||||
var uiActions = require('../ui/actions');
|
||||
|
||||
const GoogleMiddleware = (function(){
|
||||
|
||||
// A snapcast request is an alias of the Pusher request
|
||||
const request = (store, params = null, response_callback = null, error_callback = null) => {
|
||||
store.dispatch(
|
||||
pusherActions.request(
|
||||
'snapcast_instruct',
|
||||
params,
|
||||
response_callback,
|
||||
error_callback
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
return store => next => action => {
|
||||
var google = store.getState().google;
|
||||
|
||||
switch(action.type){
|
||||
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
default:
|
||||
return next(action);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
export default GoogleMiddleware
|
||||
14
src/js/services/google/reducer.js
Executable file
14
src/js/services/google/reducer.js
Executable file
@ -0,0 +1,14 @@
|
||||
|
||||
export default function reducer(google = {}, action){
|
||||
switch (action.type){
|
||||
|
||||
case 'GOOGLE_SET':
|
||||
return Object.assign({}, google, action.data);
|
||||
|
||||
default:
|
||||
return google
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user