From 19323ed64553c54f2e49328de6be4473661bfea2 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Wed, 22 Mar 2017 08:42:26 +1300 Subject: [PATCH] Pusher errors; Right-clickable now playing album; Clickable links fixes #82 --- mopidy_iris/core.py | 12 ++++++++++-- src/js/components/FullPlayer.js | 15 ++++++++++++++- src/js/services/pusher/middleware.js | 4 ++++ src/js/services/spotify/actions.js | 8 +++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/mopidy_iris/core.py b/mopidy_iris/core.py index 15e3cdd3..f4859ab7 100755 --- a/mopidy_iris/core.py +++ b/mopidy_iris/core.py @@ -304,7 +304,9 @@ class IrisCore(object): except: logger.error('IrisFrontend: access_token missing or invalid') self.broadcast({ - 'error': 'Could not get radio tracks: access_token missing or invalid' + 'type': 'error', + 'message': 'Could not get radio tracks: access_token missing or invalid', + 'source': 'load_more_tracks' }) try: @@ -318,6 +320,11 @@ class IrisCore(object): return uris except: logger.error('IrisFrontend: Failed to fetch Spotify recommendations') + self.broadcast({ + 'type': 'error', + 'message': 'Could not get radio tracks', + 'source': 'load_more_tracks' + }) return False @@ -329,7 +336,8 @@ class IrisCore(object): if not uris: self.broadcast({ - 'error': 'Could not fetch tracklist length', + 'type': 'error', + 'message': 'Could not fetch tracklist length', 'source': 'check_for_radio_update' }) logger.warning('IrisFrontend: Could not fetch tracklist length') diff --git a/src/js/components/FullPlayer.js b/src/js/components/FullPlayer.js index 78d700a4..fe563cdd 100755 --- a/src/js/components/FullPlayer.js +++ b/src/js/components/FullPlayer.js @@ -10,6 +10,7 @@ import ArtistSentence from './ArtistSentence' import Thumbnail from './Thumbnail' import Dater from './Dater' +import * as uiActions from '../services/ui/actions' import * as mopidyActions from '../services/mopidy/actions' class FullPlayer extends React.Component{ @@ -18,6 +19,17 @@ class FullPlayer extends React.Component{ super(props); } + handleContextMenu(e,item){ + e.preventDefault() + var data = { + e: e, + context: 'album', + uris: [item.uri], + items: [item] + } + this.props.uiActions.showContextMenu(data) + } + renderPlayButton(){ var button = this.props.mopidyActions.play()}> if( this.props.play_state == 'playing' ){ @@ -65,7 +77,7 @@ class FullPlayer extends React.Component{ var link = null if( this.props.current_track.album.uri ) link = '/album/'+this.props.current_track.album.uri return ( - + this.handleContextMenu(e,this.props.current_track.album)}> ) @@ -134,6 +146,7 @@ const mapStateToProps = (state, ownProps) => { const mapDispatchToProps = (dispatch) => { return { + uiActions: bindActionCreators(uiActions, dispatch), mopidyActions: bindActionCreators(mopidyActions, dispatch) } } diff --git a/src/js/services/pusher/middleware.js b/src/js/services/pusher/middleware.js index 23998ba2..b90871a3 100755 --- a/src/js/services/pusher/middleware.js +++ b/src/js/services/pusher/middleware.js @@ -337,6 +337,10 @@ const PusherMiddleware = (function(){ ) break; + case 'PUSHER_ERROR': + store.dispatch(uiActions.createNotification(action.message, 'bad')) + break; + // This action is irrelevant to us, pass it on to the next middleware default: return next(action); diff --git a/src/js/services/spotify/actions.js b/src/js/services/spotify/actions.js index b3b363ac..9ac3a639 100755 --- a/src/js/services/spotify/actions.js +++ b/src/js/services/spotify/actions.js @@ -905,6 +905,11 @@ export function getPlaylist( uri ){ sendRequest( dispatch, getState, 'users/'+ helpers.getFromUri('userid',uri) +'/playlists/'+ helpers.getFromUri('playlistid',uri) +'?market='+getState().spotify.country ) .then( response => { + // convert links in description + var description = response.description + description = description.replace('