Showing system spotify user
This commit is contained in:
@ -194,7 +194,7 @@ class IrisFrontend(pykka.ThreadingActor, CoreListener):
|
||||
def get_config( self ):
|
||||
all_config = self.config
|
||||
config = {
|
||||
"spotify_user": all_config['spotify']['username'],
|
||||
"spotify_username": all_config['spotify']['username'],
|
||||
"country": all_config['iris']['country'],
|
||||
"locale": all_config['iris']['locale']
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
var pusherActions = require('./actions.js')
|
||||
var uiActions = require('../ui/actions.js')
|
||||
var helpers = require('../../helpers.js')
|
||||
var uiActions = require('../ui/actions.js')
|
||||
var pusherActions = require('./actions.js')
|
||||
var spotifyActions = require('../spotify/actions.js')
|
||||
|
||||
const PusherMiddleware = (function(){
|
||||
|
||||
@ -117,6 +118,9 @@ const PusherMiddleware = (function(){
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch({ type: 'CONFIG', config: response.data.config })
|
||||
if (response.data.config.spotify_username){
|
||||
store.dispatch(spotifyActions.getUser('spotify:user:'+response.data.config.spotify_username))
|
||||
}
|
||||
var spotify = store.getState().spotify
|
||||
if (!spotify.country || !spotify.locale){
|
||||
store.dispatch({ type: 'SPOTIFY_SET_CONFIG', config: response.data.config })
|
||||
|
||||
@ -81,21 +81,23 @@ class Settings extends React.Component{
|
||||
}
|
||||
|
||||
renderSpotifyUser(){
|
||||
|
||||
var user = null
|
||||
if (this.props.spotify.me && this.props.spotify.authorized){
|
||||
user = this.props.spotify.me
|
||||
} else if (this.props.ui.config && this.props.ui.config.spotify_username){
|
||||
if (this.props.ui.users && typeof(this.props.ui.users['spotify:user:'+this.props.ui.config.spotify_username]) !== 'undefined'){
|
||||
user = this.props.ui.users['spotify:user:'+this.props.ui.config.spotify_username]
|
||||
}
|
||||
}
|
||||
|
||||
if (user){
|
||||
return (
|
||||
<Link className="user" to={global.baseURL+'user/'+this.props.spotify.me.uri}>
|
||||
<Thumbnail circle={true} size="small" images={this.props.spotify.me.images} />
|
||||
<Link className="user" to={global.baseURL+'user/'+user.uri}>
|
||||
<Thumbnail circle={true} size="small" images={user.images} />
|
||||
<span className="user-name">
|
||||
{ this.props.spotify.me.display_name ? this.props.spotify.me.display_name : this.props.spotify.me.id }
|
||||
</span>
|
||||
</Link>
|
||||
)
|
||||
} else if (this.props.ui.config && this.props.ui.config.spotify_user){
|
||||
return (
|
||||
<Link className="user" to={global.baseURL+'user/spotify:user:'+this.props.ui.config.spotify_user}>
|
||||
<Thumbnail circle={true} size="small" />
|
||||
<span className="user-name">
|
||||
{this.props.ui.config.spotify_user} <span className="grey-text">(As defined in mopidy.config)</span>
|
||||
{user.display_name ? user.display_name : user.username}
|
||||
{!this.props.spotify.authorized ? <span className="grey-text"> (As defined in config file)</span> : null}
|
||||
</span>
|
||||
</Link>
|
||||
)
|
||||
@ -104,7 +106,8 @@ class Settings extends React.Component{
|
||||
<Link className="user">
|
||||
<Thumbnail circle={true} size="small" />
|
||||
<span className="user-name">
|
||||
Default user <span className="grey-text">(As defined in mopidy.config)</span>
|
||||
Default user
|
||||
<span className="grey-text"> (As defined in config file)</span>
|
||||
</span>
|
||||
</Link>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user