Window title reflects current view; Hosted-instance tracking

This commit is contained in:
James Barnsley
2018-06-29 14:26:06 +12:00
parent 29f60071a9
commit 82fa3354c6
24 changed files with 23258 additions and 21027 deletions

View File

@ -12,6 +12,7 @@ import ContextMenuTrigger from '../components/ContextMenuTrigger'
import Icon from '../components/Icon'
import * as helpers from '../helpers'
import * as uiActions from '../services/ui/actions'
import * as mopidyActions from '../services/mopidy/actions'
import * as spotifyActions from '../services/spotify/actions'
@ -22,6 +23,7 @@ class User extends React.Component{
}
componentDidMount(){
this.setWindowTitle();
this.loadUser();
}
@ -29,6 +31,18 @@ class User extends React.Component{
if (nextProps.params.uri != this.props.params.uri){
this.loadUser(nextProps);
}
if (!this.props.user && nextProps.user){
this.setWindowTitle(nextProps.user);
}
}
setWindowTitle(user = this.props.user){
if (user){
this.props.uiActions.setWindowTitle(user.name+" (user)");
} else{
this.props.uiActions.setWindowTitle("User");
}
}
loadUser(props = this.props){
@ -129,6 +143,7 @@ const mapStateToProps = (state, ownProps) => {
const mapDispatchToProps = (dispatch) => {
return {
uiActions: bindActionCreators(uiActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}