Receiving connection updates

This commit is contained in:
James Barnsley
2016-10-28 10:48:55 +13:00
parent 696e385b7e
commit 64e5472e2c
4 changed files with 28 additions and 14 deletions

View File

@ -20,24 +20,13 @@ class Settings extends React.Component{
this.state = {
mopidy_host: this.props.mopidy.host,
mopidy_port: this.props.mopidy.port,
pusher_username: '',
pusher_username: this.props.pusher.username,
pusher_port: this.props.pusher.port,
spotify_country: this.props.spotify.country,
spotify_locale: this.props.spotify.locale
};
}
componentWillReceiveProps( newProps ){
if( this.props.pusher.connectionid != newProps.pusher.connectionid ){
function isCurrentConnection(connection){
return connection.connectionid == newProps.pusher.connectionid;
}
var currentConnection = newProps.pusher.connections.find(isCurrentConnection);
this.setState({ pusher_username: currentConnection.username })
}
}
resetAllSettings(){
localStorage.clear();
window.location.reload(true);