try to fix
This commit is contained in:
parent
2a1cc0292c
commit
c878702331
3 changed files with 19 additions and 9 deletions
|
@ -72,10 +72,18 @@ class Light extends Component {
|
||||||
.saveDevice({ ...this.props.stateOrDevice, on })
|
.saveDevice({ ...this.props.stateOrDevice, on })
|
||||||
.catch((err) => console.error("regular light update error", err));
|
.catch((err) => console.error("regular light update error", err));
|
||||||
} else {
|
} else {
|
||||||
this.props.updateState(
|
this.props
|
||||||
{ id: this.props.sceneState.id, on: on },
|
.updateState(
|
||||||
|
{
|
||||||
|
id: this.props.sceneState.id,
|
||||||
|
on: on,
|
||||||
|
sceneId: this.props.sceneState.sceneId,
|
||||||
|
},
|
||||||
this.props.sceneState.kind
|
this.props.sceneState.kind
|
||||||
);
|
)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ export const RemoteService = {
|
||||||
|
|
||||||
return Endpoint.put(url, {}, data)
|
return Endpoint.put(url, {}, data)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
dispatch(actions.stateUpdate(res.data));
|
dispatch(actions.stateSave(res.data));
|
||||||
return res.data;
|
return res.data;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
|
@ -164,9 +164,6 @@ function reducer(previousState, action) {
|
||||||
|
|
||||||
newState = update(newState, change);
|
newState = update(newState, change);
|
||||||
|
|
||||||
break;
|
|
||||||
case "STATE_UPDATE":
|
|
||||||
//update the state
|
|
||||||
break;
|
break;
|
||||||
case "DEVICES_UPDATE":
|
case "DEVICES_UPDATE":
|
||||||
change = null;
|
change = null;
|
||||||
|
@ -295,7 +292,12 @@ function reducer(previousState, action) {
|
||||||
sceneStates: { [action.sceneState.id]: { $set: action.sceneState } },
|
sceneStates: { [action.sceneState.id]: { $set: action.sceneState } },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (previousState.scenes[action.sceneState.sceneId]) {
|
if (
|
||||||
|
!previousState.scenes[action.sceneState.sceneId].sceneStates[
|
||||||
|
action.sceneState.id
|
||||||
|
]
|
||||||
|
) {
|
||||||
|
console.log("Ciao");
|
||||||
change.scenes = {
|
change.scenes = {
|
||||||
[action.sceneState.sceneId]: {
|
[action.sceneState.sceneId]: {
|
||||||
sceneStates: {
|
sceneStates: {
|
||||||
|
|
Loading…
Reference in a new issue