fix to stateOrDevice

This commit is contained in:
Jacob Salvi 2020-04-25 17:45:22 +02:00
parent fd5c28b1c9
commit b301c97212
6 changed files with 22 additions and 10 deletions

View File

@ -110,8 +110,7 @@ const mapStateToProps = (state, ownProps) => ({
if(state.active.activeTab==="Devices"){
return state.devices[ownProps.id];
}else{
const sceneState = state.sceneStates[ownProps.id];
return state.devices[sceneState];
return state.sceneStates[ownProps.id];
}
},
//device: state.devices[ownProps.id],

View File

@ -133,8 +133,7 @@ const mapStateToProps = (state, ownProps) => ({
if(state.active.activeTab==="Devices"){
return state.devices[ownProps.id];
}else{
const sceneState = state.sceneStates[ownProps.id];
return state.devices[sceneState];
return state.sceneStates[ownProps.id];
}
},
});

View File

@ -160,8 +160,7 @@ const mapStateToProps = (state, ownProps) => ({
if(state.active.activeTab==="Devices"){
return state.devices[ownProps.id];
}else{
const sceneState = state.sceneStates[ownProps.id];
return state.devices[sceneState];
return state.sceneStates[ownProps.id];
}
},
//device: state.devices[ownProps.id],

View File

@ -196,8 +196,7 @@ const mapStateToProps = (state, ownProps) => ({
if(state.active.activeTab==="Devices"){
return state.devices[ownProps.id];
}else{
const sceneState = state.sceneStates[ownProps.id];
return state.devices[sceneState];
return state.sceneStates[ownProps.id];
}
},
});

View File

@ -72,8 +72,7 @@ const mapStateToProps = (state, ownProps) => ({
if(state.active.activeTab==="Devices"){
return state.devices[ownProps.id];
}else{
const sceneState = state.sceneStates[ownProps.id];
return state.devices[sceneState];
return state.sceneStates[ownProps.id];
}
},
});

View File

@ -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
* data.id is truthy, then a update call is performed,