Skip to content

Commit

Permalink
More debug options; Queue metadata changed handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jaedb committed Feb 21, 2017
1 parent 218c4b1 commit 83d7f95
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/js/services/mopidy/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
5 changes: 4 additions & 1 deletion src/js/services/pusher/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ){
Expand Down Expand Up @@ -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)
}
)
Expand Down
4 changes: 2 additions & 2 deletions src/js/services/ui/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++ ){

Expand Down
18 changes: 17 additions & 1 deletion src/js/views/Debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })} />
<span className="label">Log actions in developer console</span>
<span className="label">Log actions</span>
</label>
<label>
<input
type="checkbox"
name="emulate_touch"
checked={ this.props.log_mopidy }
onChange={ e => this.props.uiActions.set({ log_mopidy: !this.props.log_mopidy })} />
<span className="label">Log Mopidy</span>
</label>
<label>
<input
type="checkbox"
name="emulate_touch"
checked={ this.props.log_pusher }
onChange={ e => this.props.uiActions.set({ log_pusher: !this.props.log_pusher })} />
<span className="label">Log Pusher</span>
</label>
<label>
<input
Expand Down

0 comments on commit 83d7f95

Please sign in to comment.