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}
|
tab={this.props.tab}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "":
|
|
||||||
return "";
|
|
||||||
default:
|
default:
|
||||||
throw new Error("Device type unknown");
|
//throw new Error("Device type unknown");
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
{
|
||||||
|
if (this.props.type !== "") {
|
||||||
return (
|
return (
|
||||||
<Segment>
|
<Segment>
|
||||||
<Grid columns={2}>
|
<Grid columns={2}>
|
||||||
|
@ -166,13 +167,19 @@ class Device extends React.Component {
|
||||||
) : (
|
) : (
|
||||||
<Grid.Column textAlign="center">
|
<Grid.Column textAlign="center">
|
||||||
<Header as="h3">
|
<Header as="h3">
|
||||||
{this.props.stateOrDevice ? this.props.stateOrDevice.name : ""}
|
{this.props.stateOrDevice
|
||||||
|
? this.props.stateOrDevice.name
|
||||||
|
: ""}
|
||||||
</Header>
|
</Header>
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Segment>
|
</Segment>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -211,9 +218,14 @@ const mapStateToProps = (state, ownProps) => ({
|
||||||
},
|
},
|
||||||
get type() {
|
get type() {
|
||||||
if (state.active.activeTab === "Scenes") {
|
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;
|
const id = state.sceneStates[ownProps.id].deviceId;
|
||||||
console.log(id, state.devices[id].kind);
|
console.log(id, state.devices[id].kind);
|
||||||
return state.devices[id].kind;
|
return state.devices[id].kind;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,9 @@ function reducer(previousState, action) {
|
||||||
|
|
||||||
const updateSceneStateProps = (state) => {
|
const updateSceneStateProps = (state) => {
|
||||||
change.sceneStates[state.id] = {};
|
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) {
|
switch (action.type) {
|
||||||
|
@ -104,7 +106,7 @@ function reducer(previousState, action) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "STATE_UPDATE":
|
case "STATE_UPDATE":
|
||||||
console.log(action.sceneStates);
|
//console.log(action.sceneStates);
|
||||||
newState = previousState;
|
newState = previousState;
|
||||||
change = null;
|
change = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue