Fetching status on render
This commit is contained in:
@ -17,6 +17,18 @@ class Snapcast extends React.Component{
|
||||
super(props)
|
||||
}
|
||||
|
||||
componentDidMount(){
|
||||
if (this.props.pusher_connected){
|
||||
this.props.pusherActions.getSnapcast();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(newProps){
|
||||
if (!this.props.pusher_connected && newProps.pusher_connected){
|
||||
this.props.pusherActions.getSnapcast();
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
if (!this.props.snapcast){
|
||||
return null;
|
||||
@ -51,6 +63,7 @@ class Snapcast extends React.Component{
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
pusher_connected: state.pusher.connected,
|
||||
snapcast: state.pusher.snapcast
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +188,6 @@ const PusherMiddleware = (function(){
|
||||
store.dispatch(pusherActions.getConfig());
|
||||
store.dispatch(pusherActions.getVersion());
|
||||
store.dispatch(pusherActions.getRadio());
|
||||
//store.dispatch(pusherActions.getSnapcast());
|
||||
store.dispatch(pusherActions.getQueueMetadata());
|
||||
|
||||
next(action);
|
||||
|
||||
@ -235,9 +235,14 @@ export function refreshingToken(){
|
||||
}
|
||||
}
|
||||
|
||||
export function authorizationReceived(data){
|
||||
export function tokenChanged(spotify_token){
|
||||
return {
|
||||
type: 'SPOTIFY_TOKEN_CHANGED',
|
||||
spotify_token: spotify_token
|
||||
}
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
export function authorizationReceived(data){
|
||||
|
||||
// This is just an alias to open the modal
|
||||
return uiActions.openModal('receive_authorization', data);
|
||||
|
||||
@ -65,7 +65,13 @@ export default function reducer(spotify = {}, action){
|
||||
refreshing_token: false,
|
||||
access_token: action.data.access_token,
|
||||
token_expiry: action.data.token_expiry
|
||||
})
|
||||
});
|
||||
|
||||
case 'SPOTIFY_TOKEN_CHANGED':
|
||||
return Object.assign({}, spotify, {
|
||||
access_token: action.spotify_token.access_token,
|
||||
token_expiry: action.spotify_token.token_expiry
|
||||
});
|
||||
|
||||
case 'SPOTIFY_DISCONNECTED':
|
||||
return Object.assign({}, spotify, { connected: false, connecting: false })
|
||||
|
||||
Reference in New Issue
Block a user