Adding and updating Servers, fixes #524
This commit is contained in:
@ -284,10 +284,20 @@ const MopidyMiddleware = (function () {
|
||||
});
|
||||
break;
|
||||
|
||||
case 'MOPIDY_SET_CONNECTION':
|
||||
store.dispatch(mopidyActions.set(action.data));
|
||||
case 'MOPIDY_UPDATE_SERVER':
|
||||
let servers = store.getState().mopidy.servers;
|
||||
servers[action.server.id] = { ...servers[action.server.id], ...action.server };
|
||||
store.dispatch(mopidyActions.updateServers(servers));
|
||||
break;
|
||||
|
||||
// Wait 250 ms and then retry connection
|
||||
case 'MOPIDY_SET_CURRENT_SERVER':
|
||||
store.dispatch(mopidyActions.set({
|
||||
current_server: action.server.id,
|
||||
host: action.server.host,
|
||||
port: action.server.port
|
||||
}));
|
||||
|
||||
// Wait a moment for store to update, then attempt connection
|
||||
setTimeout(
|
||||
() => {
|
||||
store.dispatch(mopidyActions.connect());
|
||||
@ -297,6 +307,12 @@ const MopidyMiddleware = (function () {
|
||||
);
|
||||
break;
|
||||
|
||||
case 'MOPIDY_REMOVE_SERVER':
|
||||
let remaining_servers = store.getState().mopidy.servers;
|
||||
delete remaining_servers[action.id];
|
||||
store.dispatch(mopidyActions.updateServers(remaining_servers));
|
||||
break;
|
||||
|
||||
case 'SET_WINDOW_FOCUS':
|
||||
|
||||
// Focus has just been regained
|
||||
|
||||
Reference in New Issue
Block a user