Simplifying broadcasts (removing silly action namespacing)
This commit is contained in:
@ -44,21 +44,21 @@ export function getConnections(){
|
||||
export function connectionAdded(connection){
|
||||
return {
|
||||
type: 'PUSHER_CONNECTION_ADDED',
|
||||
connection: connection.connection
|
||||
connection: connection
|
||||
}
|
||||
}
|
||||
|
||||
export function connectionChanged(connection){
|
||||
return {
|
||||
type: 'PUSHER_CONNECTION_CHANGED',
|
||||
connection: connection.connection
|
||||
connection: connection
|
||||
}
|
||||
}
|
||||
|
||||
export function connectionRemoved(connection){
|
||||
return {
|
||||
type: 'PUSHER_CONNECTION_REMOVED',
|
||||
connection: connection.connection
|
||||
connection: connection
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ export function getQueueMetadata(){
|
||||
export function queueMetadataChanged(queue_metadata){
|
||||
return {
|
||||
type: 'PUSHER_QUEUE_METADATA_CHANGED',
|
||||
queue_metadata: queue_metadata.queue_metadata
|
||||
queue_metadata: queue_metadata
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,39 +59,28 @@ const PusherMiddleware = (function(){
|
||||
));
|
||||
} else {
|
||||
|
||||
// Split our method into our action creator reference (eg pusherActions.createNotification(params))
|
||||
var method = message.method.split('.');
|
||||
var actions_library = method[0]+'Actions';
|
||||
|
||||
switch (method[0]){
|
||||
case 'core':
|
||||
var action = coreActions[method[1]];
|
||||
switch (message.method){
|
||||
case 'connection_added':
|
||||
store.dispatch(pusherActions.connectionAdded(message.params.connection));
|
||||
break;
|
||||
case 'ui':
|
||||
var action = uiActions[method[1]];
|
||||
case 'connection_changed':
|
||||
store.dispatch(pusherActions.connectionChanged(message.params.connection));
|
||||
break;
|
||||
case 'pusher':
|
||||
var action = pusherActions[method[1]];
|
||||
case 'connection_removed':
|
||||
store.dispatch(pusherActions.connectionRemoved(message.params.connection));
|
||||
break;
|
||||
case 'lastfm':
|
||||
var action = lastfmActions[method[1]];
|
||||
case 'queue_metadata_changed':
|
||||
store.dispatch(pusherActions.queueMetadataChanged(message.params.queue_metadata));
|
||||
break;
|
||||
case 'mopidy':
|
||||
var action = mopidyActions[method[1]];
|
||||
case 'spotify_token_changed':
|
||||
store.dispatch(spotifyActions.tokenChanged(message.params.spotify_token));
|
||||
break;
|
||||
case 'spotify':
|
||||
var action = spotifyActions[method[1]];
|
||||
case 'spotify_authorization_received':
|
||||
store.dispatch(uiActions.openModal('receive_authorization', message.params));
|
||||
break;
|
||||
case 'notification':
|
||||
store.dispatch(uiActions.createNotification(message.params.notification));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!action){
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.params){
|
||||
store.dispatch(action(message.params));
|
||||
} else {
|
||||
store.dispatch(action());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user