Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1280: When switching dashboard, similar box should be refreshed #1283

Merged
merged 7 commits into from
Sep 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix temperature in room box
  • Loading branch information
Pierre-Gilles committed Sep 10, 2021
commit 6ffadf7efe1d8ab5b59566f23daa2cb9ec4f6e9c
19 changes: 16 additions & 3 deletions front/src/components/boxs/room-temperature/RoomTemperature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ const RoomTemperatureBox = ({ children, ...props }) => (
</div>
);

@connect('DashboardBoxDataTemperatureInRoom,DashboardBoxStatusTemperatureInRoom', actions)
class RoomTemperatureBoxComponent extends Component {
componentDidMount() {
refreshData = () => {
this.props.getTemperatureInRoom(this.props.box, this.props.x, this.props.y);
};

componentDidMount() {
this.refreshData();
}

componentDidUpdate(previousProps) {
const roomChanged = get(previousProps, 'box.room') !== get(this.props, 'box.room');
if (roomChanged) {
this.refreshData();
}
}

render(props, {}) {
Expand All @@ -47,4 +57,7 @@ class RoomTemperatureBoxComponent extends Component {
}
}

export default RoomTemperatureBoxComponent;
export default connect(
'DashboardBoxDataTemperatureInRoom,DashboardBoxStatusTemperatureInRoom',
actions
)(RoomTemperatureBoxComponent);