Removing defunct Spotify backend_username in favor of api/me response, fixes #211
This commit is contained in:
@ -122,9 +122,7 @@ const PusherMiddleware = (function(){
|
|||||||
|
|
||||||
response.type = 'PUSHER_CONFIG'
|
response.type = 'PUSHER_CONFIG'
|
||||||
store.dispatch(response)
|
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
|
var core = store.getState().core
|
||||||
if (!core.country || !core.locale){
|
if (!core.country || !core.locale){
|
||||||
store.dispatch(coreActions.set({
|
store.dispatch(coreActions.set({
|
||||||
@ -348,15 +346,9 @@ const PusherMiddleware = (function(){
|
|||||||
store.dispatch(spotifyActions.set({
|
store.dispatch(spotifyActions.set({
|
||||||
locale: (action.config.locale ? action.config.locale : null),
|
locale: (action.config.locale ? action.config.locale : null),
|
||||||
country: (action.config.country ? action.config.country : null),
|
country: (action.config.country ? action.config.country : null),
|
||||||
authorization_url: (action.config.authorization_url ? action.config.authorization_url : null),
|
authorization_url: (action.config.authorization_url ? action.config.authorization_url : null)
|
||||||
backend_username: (action.config.spotify_username ? action.config.spotify_username : 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 )
|
next( action )
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
@ -1027,8 +1027,6 @@ export function getUserPlaylists(user_uri){
|
|||||||
var can_edit = false
|
var can_edit = false
|
||||||
if (getState().spotify.me && response.items[i].owner.id == getState().spotify.me.id){
|
if (getState().spotify.me && response.items[i].owner.id == getState().spotify.me.id){
|
||||||
can_edit = true
|
can_edit = true
|
||||||
} else if (response.items[i].owner.id == getState().backend_username){
|
|
||||||
can_edit = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playlists.push(Object.assign(
|
playlists.push(Object.assign(
|
||||||
|
|||||||
@ -104,15 +104,7 @@ class Settings extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderSpotifyUser(){
|
renderSpotifyUser(){
|
||||||
|
var user = this.props.spotify.me
|
||||||
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]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user){
|
if (user){
|
||||||
return (
|
return (
|
||||||
@ -123,15 +115,6 @@ class Settings extends React.Component {
|
|||||||
</span>
|
</span>
|
||||||
</Link>
|
</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 {
|
} else {
|
||||||
return (
|
return (
|
||||||
<Link className="user">
|
<Link className="user">
|
||||||
|
|||||||
@ -48,21 +48,8 @@ class User extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
isMe(){
|
isMe(){
|
||||||
let userid = helpers.getFromUri('userid',this.props.params.uri)
|
let userid = helpers.getFromUri('userid',this.props.params.uri);
|
||||||
switch (this.props.spotify_authentication_provider){
|
return (this.props.me && this.props.me.id && this.props.me.id == userid);
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
@ -131,8 +118,6 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
return {
|
return {
|
||||||
load_queue: state.ui.load_queue,
|
load_queue: state.ui.load_queue,
|
||||||
spotify_authorized: state.spotify.authorization,
|
spotify_authorized: state.spotify.authorization,
|
||||||
spotify_authentication_provider: state.spotify.authentication_provider,
|
|
||||||
spotify_backend_username: state.spotify.backend_username,
|
|
||||||
me: state.spotify.me,
|
me: state.spotify.me,
|
||||||
playlists: state.core.playlists,
|
playlists: state.core.playlists,
|
||||||
user: (state.core.users && state.core.users[ownProps.params.uri] !== undefined ? state.core.users[ownProps.params.uri] : false),
|
user: (state.core.users && state.core.users[ownProps.params.uri] !== undefined ? state.core.users[ownProps.params.uri] : false),
|
||||||
|
|||||||
@ -264,7 +264,7 @@ const mapStateToProps = (state, ownProps) => {
|
|||||||
spotify_library_playlists: state.spotify.library_playlists,
|
spotify_library_playlists: state.spotify.library_playlists,
|
||||||
spotify_library_playlists_status: state.spotify.library_playlists_status,
|
spotify_library_playlists_status: state.spotify.library_playlists_status,
|
||||||
load_queue: state.ui.load_queue,
|
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,
|
view: state.ui.library_playlists_view,
|
||||||
source: (state.ui.library_playlists_source ? state.ui.library_playlists_source : 'all'),
|
source: (state.ui.library_playlists_source ? state.ui.library_playlists_source : 'all'),
|
||||||
sort: (state.ui.library_playlists_sort ? state.ui.library_playlists_sort : 'name'),
|
sort: (state.ui.library_playlists_sort ? state.ui.library_playlists_sort : 'name'),
|
||||||
|
|||||||
Reference in New Issue
Block a user