fixed problem in scene state
This commit is contained in:
parent
d231ce7e84
commit
2d9bdf63fb
2 changed files with 60 additions and 46 deletions
|
@ -127,14 +127,15 @@ class Device extends React.Component {
|
|||
tab={this.props.tab}
|
||||
/>
|
||||
);
|
||||
case "":
|
||||
return "";
|
||||
default:
|
||||
throw new Error("Device type unknown");
|
||||
//throw new Error("Device type unknown");
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
{
|
||||
if (this.props.type !== "") {
|
||||
return (
|
||||
<Segment>
|
||||
<Grid columns={2}>
|
||||
|
@ -166,13 +167,19 @@ class Device extends React.Component {
|
|||
) : (
|
||||
<Grid.Column textAlign="center">
|
||||
<Header as="h3">
|
||||
{this.props.stateOrDevice ? this.props.stateOrDevice.name : ""}
|
||||
{this.props.stateOrDevice
|
||||
? this.props.stateOrDevice.name
|
||||
: ""}
|
||||
</Header>
|
||||
</Grid.Column>
|
||||
)}
|
||||
</Grid>
|
||||
</Segment>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@ -211,9 +218,14 @@ const mapStateToProps = (state, ownProps) => ({
|
|||
},
|
||||
get type() {
|
||||
if (state.active.activeTab === "Scenes") {
|
||||
if (state.sceneStates[ownProps.id]) {
|
||||
console.log(state.sceneStates[ownProps.id], ownProps.id);
|
||||
const id = state.sceneStates[ownProps.id].deviceId;
|
||||
console.log(id, state.devices[id].kind);
|
||||
return state.devices[id].kind;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,9 @@ function reducer(previousState, action) {
|
|||
|
||||
const updateSceneStateProps = (state) => {
|
||||
change.sceneStates[state.id] = {};
|
||||
change.sceneStates[state.id] = { $set: state.id };
|
||||
for (const key in state) {
|
||||
change.sceneStates[state.id][key] = { $set: state[key] };
|
||||
}
|
||||
};
|
||||
|
||||
switch (action.type) {
|
||||
|
@ -104,7 +106,7 @@ function reducer(previousState, action) {
|
|||
}
|
||||
break;
|
||||
case "STATE_UPDATE":
|
||||
console.log(action.sceneStates);
|
||||
//console.log(action.sceneStates);
|
||||
newState = previousState;
|
||||
change = null;
|
||||
|
||||
|
|
Loading…
Reference in a new issue