From 521186086c854ddaa4a41ca215ed893452950840 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Wed, 27 Sep 2017 15:29:17 +1300 Subject: [PATCH] Removing defunct Spotify backend_username in favor of api/me response, fixes #211 --- src/js/services/pusher/middleware.js | 12 ++---------- src/js/services/spotify/actions.js | 2 -- src/js/views/Settings.js | 19 +------------------ src/js/views/User.js | 19 ++----------------- src/js/views/library/LibraryPlaylists.js | 2 +- 5 files changed, 6 insertions(+), 48 deletions(-) diff --git a/src/js/services/pusher/middleware.js b/src/js/services/pusher/middleware.js index 6ffc82b4..27b2ffd0 100755 --- a/src/js/services/pusher/middleware.js +++ b/src/js/services/pusher/middleware.js @@ -122,9 +122,7 @@ const PusherMiddleware = (function(){ response.type = 'PUSHER_CONFIG' store.dispatch(response) - if (response.config.spotify_username && store.getState().spotify.enabled){ - store.dispatch(spotifyActions.getUser('spotify:user:'+response.config.spotify_username)) - } + var core = store.getState().core if (!core.country || !core.locale){ store.dispatch(coreActions.set({ @@ -348,15 +346,9 @@ const PusherMiddleware = (function(){ store.dispatch(spotifyActions.set({ locale: (action.config.locale ? action.config.locale : null), country: (action.config.country ? action.config.country : null), - authorization_url: (action.config.authorization_url ? action.config.authorization_url : null), - backend_username: (action.config.spotify_username ? action.config.spotify_username : null) + authorization_url: (action.config.authorization_url ? action.config.authorization_url : null) })) - // Get our backend_username user - if (store.getState().spotify.access !== 'none' && (!store.getState().core.users || !store.getState().core.users[action.config.spotify_username])){ - store.dispatch(spotifyActions.getUser(action.config.spotify_username)) - } - next( action ) break diff --git a/src/js/services/spotify/actions.js b/src/js/services/spotify/actions.js index 59a09fe3..6c02e102 100755 --- a/src/js/services/spotify/actions.js +++ b/src/js/services/spotify/actions.js @@ -1027,8 +1027,6 @@ export function getUserPlaylists(user_uri){ var can_edit = false if (getState().spotify.me && response.items[i].owner.id == getState().spotify.me.id){ can_edit = true - } else if (response.items[i].owner.id == getState().backend_username){ - can_edit = true } playlists.push(Object.assign( diff --git a/src/js/views/Settings.js b/src/js/views/Settings.js index 021a2cf0..f5036f87 100755 --- a/src/js/views/Settings.js +++ b/src/js/views/Settings.js @@ -104,15 +104,7 @@ class Settings extends React.Component { } renderSpotifyUser(){ - - var user = null - if (this.props.spotify.me && this.props.spotify.authorization){ - user = this.props.spotify.me - } else if (this.props.spotify.backend_username){ - if (this.props.core.users && this.props.core.users['spotify:user:'+this.props.spotify.backend_username] !== undefined){ - user = this.props.core.users['spotify:user:'+this.props.spotify.backend_username] - } - } + var user = this.props.spotify.me if (user){ return ( @@ -123,15 +115,6 @@ class Settings extends React.Component { ) - } else if (this.props.spotify.backend_username){ - return ( - - - - {this.props.spotify.backend_username} - - - ) } else { return ( diff --git a/src/js/views/User.js b/src/js/views/User.js index 46d5b789..c5674521 100755 --- a/src/js/views/User.js +++ b/src/js/views/User.js @@ -48,21 +48,8 @@ class User extends React.Component{ } isMe(){ - let userid = helpers.getFromUri('userid',this.props.params.uri) - switch (this.props.spotify_authentication_provider){ - case 'backend': - if (this.props.spotify_authorized && this.props.me){ - return userid == this.props.me.id - } - return false - break - - case 'http_api': - return userid == this.props.spotify_backend_username - - default: - return false - } + let userid = helpers.getFromUri('userid',this.props.params.uri); + return (this.props.me && this.props.me.id && this.props.me.id == userid); } render(){ @@ -131,8 +118,6 @@ const mapStateToProps = (state, ownProps) => { return { load_queue: state.ui.load_queue, spotify_authorized: state.spotify.authorization, - spotify_authentication_provider: state.spotify.authentication_provider, - spotify_backend_username: state.spotify.backend_username, me: state.spotify.me, playlists: state.core.playlists, user: (state.core.users && state.core.users[ownProps.params.uri] !== undefined ? state.core.users[ownProps.params.uri] : false), diff --git a/src/js/views/library/LibraryPlaylists.js b/src/js/views/library/LibraryPlaylists.js index d8e6df7a..b3e6844a 100755 --- a/src/js/views/library/LibraryPlaylists.js +++ b/src/js/views/library/LibraryPlaylists.js @@ -264,7 +264,7 @@ const mapStateToProps = (state, ownProps) => { spotify_library_playlists: state.spotify.library_playlists, spotify_library_playlists_status: state.spotify.library_playlists_status, load_queue: state.ui.load_queue, - me_id: (state.spotify.me ? state.spotify.me.id : (state.ui.config && state.ui.config.spotify_username ? state.ui.config.spotify_username : false)), + me_id: (state.spotify.me ? state.spotify.me.id : false), view: state.ui.library_playlists_view, source: (state.ui.library_playlists_source ? state.ui.library_playlists_source : 'all'), sort: (state.ui.library_playlists_sort ? state.ui.library_playlists_sort : 'name'),