Snapcast to BEM
This commit is contained in:
@ -8,6 +8,16 @@ export function set(data){
|
||||
}
|
||||
}
|
||||
|
||||
export function request(method, params = null, response_callback = null, error_callback = null){
|
||||
return {
|
||||
type: 'MOPIDY_REQUEST',
|
||||
method: method,
|
||||
params: params,
|
||||
response_callback: response_callback,
|
||||
error_callback: error_callback
|
||||
}
|
||||
}
|
||||
|
||||
export function connect(){
|
||||
return {
|
||||
type: 'MOPIDY_CONNECT'
|
||||
|
||||
@ -241,6 +241,28 @@ const MopidyMiddleware = (function(){
|
||||
})
|
||||
break;
|
||||
|
||||
case 'MOPIDY_REQUEST':
|
||||
request(socket, store, action.method, action.params)
|
||||
.then(
|
||||
response => {
|
||||
if (action.response_callback){
|
||||
store.dispatch(action.response_callback.call(this, response));
|
||||
}
|
||||
},
|
||||
error => {
|
||||
if (action.error_callback){
|
||||
store.dispatch(action.error_callback.call(this, error));
|
||||
} else {
|
||||
store.dispatch(coreActions.handleException(
|
||||
'Mopidy request failed',
|
||||
error,
|
||||
action.method,
|
||||
action
|
||||
));
|
||||
}
|
||||
}
|
||||
);
|
||||
break
|
||||
|
||||
/**
|
||||
* General playback
|
||||
|
||||
@ -75,9 +75,9 @@ export function connectionRemoved(connection){
|
||||
}
|
||||
}
|
||||
|
||||
export function instruct(method, params = null, response_callback = null, error_callback = null){
|
||||
export function request(method, params = null, response_callback = null, error_callback = null){
|
||||
return {
|
||||
type: 'PUSHER_INSTRUCT',
|
||||
type: 'PUSHER_REQUEST',
|
||||
method: method,
|
||||
params: params,
|
||||
response_callback: response_callback,
|
||||
|
||||
@ -244,7 +244,7 @@ const PusherMiddleware = (function(){
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'PUSHER_INSTRUCT':
|
||||
case 'PUSHER_REQUEST':
|
||||
request(store, action.method, action.params)
|
||||
.then(
|
||||
response => {
|
||||
@ -257,8 +257,10 @@ const PusherMiddleware = (function(){
|
||||
store.dispatch(action.error_callback.call(this, error));
|
||||
} else {
|
||||
store.dispatch(coreActions.handleException(
|
||||
'Instruct failed',
|
||||
error
|
||||
'Pusher request failed',
|
||||
error,
|
||||
action.method,
|
||||
action
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ const SnapcastMiddleware = (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.instruct(
|
||||
pusherActions.request(
|
||||
'snapcast_instruct',
|
||||
params,
|
||||
response_callback,
|
||||
|
||||
Reference in New Issue
Block a user