Commit e9ada991 by HaOuiha

update

parent 7f354269
......@@ -68,7 +68,8 @@ class SmartMeterDetailScreen extends Component {
componentDidUpdate = (prevProps, prevState) => {
if (
prevProps.currentSelectedData !== this.props.currentSelectedData ||
prevProps.breakerStatus !== this.props.breakerStatus
prevProps.breakerStatus !== this.props.breakerStatus ||
prevState.isPowerOn !== this.state.isPowerOn
) {
this.setMainCardData();
}
......@@ -89,10 +90,12 @@ class SmartMeterDetailScreen extends Component {
await this.props.getCurrentSelectedShadow();
await this.props.setMainStatus(value);
this.setState({ isPowerOn: this.props.desiredBreakerStatus.SM1.BK_S });
const getShadowInterval = setInterval(async () => {
this.setState(() => {
const { currentSelectedData, breakerStatus } = this.props;
if (this.props.desiredBreakerStatus === this.props.breakerStatus) {
const { currentSelectedData, breakerStatus, desiredBreakerStatus } = this.props;
if (desiredBreakerStatus.SM1.BK_S === breakerStatus.SM1.BK_S) {
clearInterval(getShadowInterval);
return {
......@@ -101,14 +104,11 @@ class SmartMeterDetailScreen extends Component {
name: currentSelectedData.name,
rcbo: currentSelectedData.rcbo,
isOnline: currentSelectedData.isOnline,
isPowerOn: breakerStatus ? breakerStatus.SM1.BK_S : false,
isPowerOn: desiredBreakerStatus ? desiredBreakerStatus.SM1.BK_S : false,
};
} else {
if (checkedTimes >= 2) {
clearInterval(getShadowInterval);
// if (this.props.desiredBreakerStatus !== this.props.breakerStatus) {
// alert('Something went wrong, Please check your smart device.');
// }
checkedTimes = 0;
}
......@@ -123,6 +123,7 @@ class SmartMeterDetailScreen extends Component {
}
});
++checkedTimes;
await this.props.getCurrentSelectedShadow();
this.setSubBreakersState();
}, 3000);
......@@ -298,9 +299,7 @@ class SmartMeterDetailScreen extends Component {
} else {
if (checkedTimes >= 2) {
clearInterval(getShadowInterval);
// if (this.props.desiredBreakerStatus !== this.props.breakerStatus) {
// alert('Something went wrong, Please check your smart device.');
// }
checkedTimes = 0;
}
return { isWaiting: false };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment