fix to stateOrDevice
This commit is contained in:
parent
fd5c28b1c9
commit
b301c97212
6 changed files with 22 additions and 10 deletions
|
@ -110,8 +110,7 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
if(state.active.activeTab==="Devices"){
|
if(state.active.activeTab==="Devices"){
|
||||||
return state.devices[ownProps.id];
|
return state.devices[ownProps.id];
|
||||||
}else{
|
}else{
|
||||||
const sceneState = state.sceneStates[ownProps.id];
|
return state.sceneStates[ownProps.id];
|
||||||
return state.devices[sceneState];
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//device: state.devices[ownProps.id],
|
//device: state.devices[ownProps.id],
|
||||||
|
|
|
@ -133,8 +133,7 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
if(state.active.activeTab==="Devices"){
|
if(state.active.activeTab==="Devices"){
|
||||||
return state.devices[ownProps.id];
|
return state.devices[ownProps.id];
|
||||||
}else{
|
}else{
|
||||||
const sceneState = state.sceneStates[ownProps.id];
|
return state.sceneStates[ownProps.id];
|
||||||
return state.devices[sceneState];
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -160,8 +160,7 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
if(state.active.activeTab==="Devices"){
|
if(state.active.activeTab==="Devices"){
|
||||||
return state.devices[ownProps.id];
|
return state.devices[ownProps.id];
|
||||||
}else{
|
}else{
|
||||||
const sceneState = state.sceneStates[ownProps.id];
|
return state.sceneStates[ownProps.id];
|
||||||
return state.devices[sceneState];
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//device: state.devices[ownProps.id],
|
//device: state.devices[ownProps.id],
|
||||||
|
|
|
@ -196,8 +196,7 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
if(state.active.activeTab==="Devices"){
|
if(state.active.activeTab==="Devices"){
|
||||||
return state.devices[ownProps.id];
|
return state.devices[ownProps.id];
|
||||||
}else{
|
}else{
|
||||||
const sceneState = state.sceneStates[ownProps.id];
|
return state.sceneStates[ownProps.id];
|
||||||
return state.devices[sceneState];
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,8 +72,7 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
if(state.active.activeTab==="Devices"){
|
if(state.active.activeTab==="Devices"){
|
||||||
return state.devices[ownProps.id];
|
return state.devices[ownProps.id];
|
||||||
}else{
|
}else{
|
||||||
const sceneState = state.sceneStates[ownProps.id];
|
return state.sceneStates[ownProps.id];
|
||||||
return state.devices[sceneState];
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -396,6 +396,23 @@ export const RemoteService = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteState: (id,type)=>{
|
||||||
|
return (dispatch) => {
|
||||||
|
let url;
|
||||||
|
if(type=="dimmableState"){
|
||||||
|
url="/dimmableState"
|
||||||
|
}else{
|
||||||
|
url="/switchableState"
|
||||||
|
}
|
||||||
|
return Endpoint.delete(url+`/${id}`)
|
||||||
|
.then((res) => dispatch(actions.statesUpdate([res.data])))
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn(`reset error`, err);
|
||||||
|
throw new RemoteError(["Network error"]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates/Updates a device with the given data. If
|
* Creates/Updates a device with the given data. If
|
||||||
* data.id is truthy, then a update call is performed,
|
* data.id is truthy, then a update call is performed,
|
||||||
|
|
Loading…
Reference in a new issue