This commit is contained in:
Claudio Maggioni (maggicl) 2020-04-28 11:56:34 +02:00
parent 835ac99a8e
commit b0b281263e
2 changed files with 534 additions and 558 deletions

File diff suppressed because it is too large Load Diff

View File

@ -256,8 +256,13 @@ function reducer(previousState, action) {
case "AUTOMATION_UPDATE": case "AUTOMATION_UPDATE":
newState = previousState; newState = previousState;
const automations = {};
for (const automation of action.automations) {
automations[automation.id] = automation;
}
change = { change = {
automations : {$set: action.automations} automations: { $set: automations },
}; };
newState = update(previousState, change); newState = update(previousState, change);
break; break;
@ -297,15 +302,13 @@ function reducer(previousState, action) {
case "AUTOMATION_SAVE": case "AUTOMATION_SAVE":
console.log("ID: ", action.automation.id); console.log("ID: ", action.automation.id);
change = { change = {
automations : {[action.automation.id] : {$set : action.automation}} automations: { [action.automation.id]: { $set: action.automation } },
}; };
newState = update(previousState, change); newState = update(previousState, change);
break; break;
case "STATE_SAVE": case "STATE_SAVE":
change = { change = {
sceneStates: { [action.sceneState.id]: { $set: action.sceneState } }, sceneStates: { [action.sceneState.id]: { $set: action.sceneState } },
@ -355,15 +358,14 @@ function reducer(previousState, action) {
break; break;
case "AUTOMATION_DELETE": case "AUTOMATION_DELETE":
change = { change = {
automations: { $unset: [action.id] }, automations: { $unset: [action.id] },
}; };
console.log("CHANGE ", change) console.log("CHANGE ", change);
console.log("Action id: ", action.id); console.log("Action id: ", action.id);
newState = update(previousState, change); newState = update(previousState, change);
console.log("NEW STATE ", newState) console.log("NEW STATE ", newState);
break; break;
case "SCENE_DELETE": case "SCENE_DELETE":
console.log("SCENE", action.sceneId); console.log("SCENE", action.sceneId);