From 83d7f952843ffbbf07ed3a9b89e24c50cc0ad87d Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Wed, 22 Feb 2017 08:54:47 +1300 Subject: [PATCH] More debug options; Queue metadata changed handler --- src/js/services/mopidy/middleware.js | 4 ++++ src/js/services/pusher/middleware.js | 5 ++++- src/js/services/ui/reducer.js | 4 ++-- src/js/views/Debug.js | 18 +++++++++++++++++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/js/services/mopidy/middleware.js b/src/js/services/mopidy/middleware.js index 23b4b0ddf..04b15dee0 100755 --- a/src/js/services/mopidy/middleware.js +++ b/src/js/services/mopidy/middleware.js @@ -14,6 +14,10 @@ const MopidyMiddleware = (function(){ // handle all manner of socket messages const handleMessage = (ws, store, type, data) => { + + // if debug enabled + if (store.getState().ui.log_mopidy) console.log('Mopidy', type, data) + switch( type ){ case 'state:online': diff --git a/src/js/services/pusher/middleware.js b/src/js/services/pusher/middleware.js index c9a9acebf..8a66ff5fb 100755 --- a/src/js/services/pusher/middleware.js +++ b/src/js/services/pusher/middleware.js @@ -23,6 +23,9 @@ const PusherMiddleware = (function(){ // handle all manner of socket messages const handleMessage = (ws, store, message) => { + // if debug enabled + if (store.getState().ui.log_pusher) console.log('Pusher', message) + // response to a request [we] made if (typeof(message.request_id) !== 'undefined' && message.request_id){ if (typeof( deferredRequests[ message.request_id ]) !== 'undefined' ){ @@ -168,7 +171,7 @@ const PusherMiddleware = (function(){ request('get_queue_metadata') .then( response => { - response.type = 'QUEUE_METADATA' + response.type = 'PUSHER_QUEUE_METADATA' store.dispatch(response) } ) diff --git a/src/js/services/ui/reducer.js b/src/js/services/ui/reducer.js index f03de435b..3d775bbcf 100755 --- a/src/js/services/ui/reducer.js +++ b/src/js/services/ui/reducer.js @@ -131,8 +131,8 @@ export default function reducer(ui = {}, action){ current_track: current_track }); - case 'QUEUE_METADATA': - case 'QUEUE_METADATA_CHANGED': + case 'PUSHER_QUEUE_METADATA': + case 'PUSHER_QUEUE_METADATA_CHANGED': var tracklist = Object.assign([], ui.current_tracklist) for( var i = 0; i < tracklist.length; i++ ){ diff --git a/src/js/views/Debug.js b/src/js/views/Debug.js index 628b38a4a..dd39cced3 100755 --- a/src/js/views/Debug.js +++ b/src/js/views/Debug.js @@ -78,7 +78,23 @@ class Debug extends React.Component{ name="emulate_touch" checked={ this.props.log_actions } onChange={ e => this.props.uiActions.set({ log_actions: !this.props.log_actions })} /> - Log actions in developer console + Log actions + + +