diff --git a/src/js/components/ContextMenu.js b/src/js/components/ContextMenu.js index 4ef0d34b..a7578330 100755 --- a/src/js/components/ContextMenu.js +++ b/src/js/components/ContextMenu.js @@ -99,6 +99,16 @@ class ContextMenu extends React.Component{ this.props.uiActions.hideContextMenu(); } + copyURIs(){ + var uris = ''; + for( var i = 0; i < this.props.context_menu.data.selected_tracks.length; i++ ){ + if( i > 0 ) uris += ',' + uris += this.props.context_menu.data.selected_tracks[i].uri + } + console.log('Yet to be implemented', uris) + this.props.uiActions.hideContextMenu() + } + renderPlaylistSubmenu(){ var playlists = [] for( var i = 0; i < this.props.playlists.length; i++ ){ @@ -135,6 +145,7 @@ class ContextMenu extends React.Component{ items = [ { handleClick: 'playQueueItem', label: 'Play' }, { handleClick: 'addToPlaylist', label: 'Add to playlist', playlists: true }, + { handleClick: 'copyURIs', label: 'Copy URIs' }, { handleClick: 'removeFromQueue', label: 'Remove' } ]; break; @@ -145,6 +156,7 @@ class ContextMenu extends React.Component{ { handleClick: 'playItemsNext', label: 'Play next' }, { handleClick: 'addToQueue', label: 'Add to queue' }, { handleClick: 'addToPlaylist', label: 'Add to playlist', playlists: true }, + { handleClick: 'copyURIs', label: 'Copy URIs' }, { handleClick: 'removeFromPlaylist', label: 'Remove' } ]; break; @@ -154,7 +166,8 @@ class ContextMenu extends React.Component{ { handleClick: 'playItems', label: 'Play' }, { handleClick: 'playItemsNext', label: 'Play next' }, { handleClick: 'addToQueue', label: 'Add to queue' }, - { handleClick: 'addToPlaylist', label: 'Add to playlist', playlists: true } + { handleClick: 'addToPlaylist', label: 'Add to playlist', playlists: true }, + { handleClick: 'copyURIs', label: 'Copy URIs' } ]; break; } diff --git a/src/js/components/FollowButton.js b/src/js/components/FollowButton.js index cc01a3e5..0e65d0a1 100755 --- a/src/js/components/FollowButton.js +++ b/src/js/components/FollowButton.js @@ -15,7 +15,9 @@ class FollowButton extends React.Component{ } componentDidMount(){ - this.props.spotifyActions.following(this.props.uri) + if( this.props.spotify_authorized && this.props.uri ){ + this.props.spotifyActions.following(this.props.uri) + } } remove(){ diff --git a/src/js/services/localstorage/middleware.js b/src/js/services/localstorage/middleware.js index 3ac79d43..68da3581 100755 --- a/src/js/services/localstorage/middleware.js +++ b/src/js/services/localstorage/middleware.js @@ -12,11 +12,7 @@ const localstorageMiddleware = (function(){ // append our state to a global variable. This gives us access to debug the store at any point window._store = store - var actions_to_log = null - //actions_to_log = 'SPOTIFY' - //actions_to_log = 'MOPIDY' - actions_to_log = 'ALBUM_' - if( action.type.startsWith(actions_to_log) ) console.log(action) + console.log(action) switch( action.type ){ diff --git a/src/js/services/spotify/reducer.js b/src/js/services/spotify/reducer.js index b354738a..ab8d2379 100755 --- a/src/js/services/spotify/reducer.js +++ b/src/js/services/spotify/reducer.js @@ -9,16 +9,6 @@ export default function reducer(spotify = {}, action){ case 'SPOTIFY_CONNECTED': return Object.assign({}, spotify, { connected: true, connecting: false }); - case 'SPOTIFY_AUTHORIZATION_GRANTED': - return Object.assign({}, spotify, { - authorizing: false, - authorized: true, - authorization: action.data, - access_token: action.data.access_token, - refresh_token: action.data.refresh_token, - token_expiry: action.data.token_expiry - }); - case 'PUSHER_SPOTIFY_TOKEN': if( spotify.authorized ) return spotify; return Object.assign({}, spotify, { @@ -29,12 +19,24 @@ export default function reducer(spotify = {}, action){ token_expiry: action.data.token_expiry }); + case 'SPOTIFY_AUTHORIZATION_GRANTED': + return Object.assign({}, spotify, { + authorizing: false, + authorized: true, + authorization: action.data, + access_token: action.data.access_token, + refresh_token: action.data.refresh_token, + token_expiry: action.data.token_expiry + }); + case 'SPOTIFY_AUTHORIZATION_REVOKED': return Object.assign({}, spotify, { authorizing: false, authorization: false, authorized: false, access_token: false, + refresh_token: false, + token_expiry: 0, me: false }); diff --git a/src/js/views/User.js b/src/js/views/User.js index bdecedb3..502a6121 100755 --- a/src/js/views/User.js +++ b/src/js/views/User.js @@ -33,7 +33,7 @@ class User extends React.Component{ loadMore(){ if( !this.props.user.playlists_more ) return - this.props.spotifyActions.getURL( this.props.user.playlists_more, 'SPOTIFY_USER_PLAYLISTS_LOADED_MORE' ); + this.props.spotifyActions.getURL( this.props.user.playlists_more, 'SPOTIFY_USER_PLAYLISTS_LOADED_MORE' ) } renderMeFlag(){ @@ -61,7 +61,7 @@ class User extends React.Component{