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