Removing defunct Spotify backend_username in favor of api/me response, fixes #211

This commit is contained in:
James Barnsley
2017-09-27 15:29:17 +13:00
parent 2fac8dee11
commit 521186086c
5 changed files with 6 additions and 48 deletions

View File

@ -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

View File

@ -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(

View File

@ -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 {
</span>
</Link>
)
} else if (this.props.spotify.backend_username){
return (
<Link className="user" to={global.baseURL+'user/spotify:user:'+this.props.spotify.backend_username}>
<Thumbnail circle={true} size="small" />
<span className="user-name">
{this.props.spotify.backend_username}
</span>
</Link>
)
} else {
return (
<Link className="user">

View File

@ -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),

View File

@ -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'),