Adding and updating Servers, fixes #524

This commit is contained in:
James Barnsley
2020-04-28 21:24:17 +12:00
parent 92292b18d7
commit 0caa780e38
17 changed files with 454 additions and 258 deletions

View File

@ -1,5 +1,6 @@
import { createRange } from '../../util/arrays';
import { generateGuid } from '../../util/helpers';
export function set(data) {
return {
@ -15,6 +16,39 @@ export function updateServer(server) {
};
}
export function updateServers(servers) {
return {
type: 'MOPIDY_UPDATE_SERVERS',
servers,
};
}
export function addServer() {
return {
type: 'MOPIDY_UPDATE_SERVER',
server: {
id: generateGuid(),
name: 'New server',
host: window.location.hostname,
port: (window.location.port ? window.location.port : (window.location.protocol === 'https:' ? '443' : '80')),
}
};
}
export function setCurrentServer(server) {
return {
type: 'MOPIDY_SET_CURRENT_SERVER',
server,
};
}
export function removeServer(id) {
return {
type: 'MOPIDY_REMOVE_SERVER',
id,
};
}
export function setConnection(data) {
return {
type: 'MOPIDY_SET_CONNECTION',