diff --git a/mopidy_iris/pusher.py b/mopidy_iris/pusher.py index 5816c5327..0ba3cd8ae 100755 --- a/mopidy_iris/pusher.py +++ b/mopidy_iris/pusher.py @@ -112,7 +112,7 @@ def open(self): logger.info( 'Pusher connection established: '+ connectionid +' ('+ clientid +'/'+ username +')' ) # broadcast to all connections that a new user has connected - broadcast( 'client_connected', client ) + broadcast( 'new_connection', client ) def select_subprotocol(self, subprotocols): # select one of our subprotocol elements and return it. This confirms the connection has been accepted. @@ -217,7 +217,7 @@ def on_message(self, message): ) # notify all clients of this change - broadcast( 'connection_updated', { 'connections': connections[messageJson['origin']['connectionid']]['client'] }) + broadcast( 'connection_updated', { 'connection': connections[messageJson['origin']['connectionid']]['client'] }) # start radio elif messageJson['action'] == 'start_radio': diff --git a/src/js/services/pusher/middleware.js b/src/js/services/pusher/middleware.js index 3c4722d59..4c38f2bb5 100755 --- a/src/js/services/pusher/middleware.js +++ b/src/js/services/pusher/middleware.js @@ -120,17 +120,17 @@ const PusherMiddleware = (function(){ request({ action: 'get_version' }) .then( response => { - store.dispatch({ type: 'PUSHER_VERSION', data: response.data }) + store.dispatch({ type: 'VERSION', data: response.data }) } ) return next(action); break; - case 'PUSHER_UPGRADING': + case 'UPGRADING': request({ action: 'perform_upgrade' }) .then( response => { - store.dispatch({ type: 'PUSHER_UPGRADE', data: response.data }) + store.dispatch({ type: 'UPGRADE', data: response.data }) } ) return next(action); @@ -139,19 +139,19 @@ const PusherMiddleware = (function(){ case 'PUSHER_SET_USERNAME': request({ action: 'set_username', username: action.username }) .then( - response => { + response => { store.dispatch({ type: 'PUSHER_USERNAME', data: { username: response.data.username }}) } ) return next(action); break; - case 'PUSHER_GET_CONNECTIONS': - case 'PUSHER_CLIENT_CONNECTED': + case 'GET_CONNECTIONS': + case 'NEW_CONNECTION': request({ action: 'get_connections' }) .then( response => { - store.dispatch({ type: 'PUSHER_CONNECTIONS', data: response.data }) + store.dispatch({ type: 'CONNECTIONS', data: response.data }) } ) return next(action); diff --git a/src/js/services/pusher/reducer.js b/src/js/services/pusher/reducer.js index 109581f8f..c62144fdd 100755 --- a/src/js/services/pusher/reducer.js +++ b/src/js/services/pusher/reducer.js @@ -23,27 +23,27 @@ export default function reducer(pusher = {}, action){ case 'PUSHER_USERNAME': return Object.assign({}, pusher, { username: action.data.username }); - case 'PUSHER_CONNECTIONS': + case 'CONNECTIONS': return Object.assign({}, pusher, { connections: action.data.connections }); - case 'PUSHER_CONNECTION_UPDATED': + case 'CONNECTION_UPDATED': function byID(connection){ - return connection.connectionid == action.data.connections.connectionid; + return connection.connectionid == action.data.connection.connectionid; } var connection = pusher.connections.find(byID); var index = pusher.connections.indexOf(connection); var connections = Object.assign([], pusher.connections); - connections[index] = action.data.connections; + connections[index] = action.data.connection; return Object.assign({}, pusher, { connections: connections }); - case 'PUSHER_VERSION': + case 'VERSION': return Object.assign({}, pusher, { version: action.data.version, upgrading: false }); - case 'PUSHER_UPGRADING': + case 'UPGRADING': return Object.assign({}, pusher, { upgrading: true }); default: