Skip to content

Commit

Permalink
Alarm: Try to fix disconnect on tablet locked mode (#1976)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles authored Dec 15, 2023
1 parent acac357 commit aabe53c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions front/src/routes/locked/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,15 @@ class Locked extends Component {
validateCode = async e => {
e.preventDefault();
try {
await this.setState({ error: false, wrongCode: false, tooManyRequests: false });
await this.setState({
error: false,
wrongCode: false,
tooManyRequests: false,
errorMessage: null,
errorStatus: null
});
const houseSelector = this.props.session.getTabletModeCurrentHouseSelector();
await this.props.httpClient.refreshAccessToken();
await this.props.httpClient.post(`/api/v1/house/${houseSelector}/disarm_with_code`, {
code: this.state.currentCode
});
Expand All @@ -132,7 +139,7 @@ class Locked extends Component {
} else if (message === 'INVALID_CODE') {
this.setState({ wrongCode: true });
} else {
this.setState({ error: true });
this.setState({ error: true, errorMessage: e.toString(), errorStatus: status });
}
}
};
Expand All @@ -143,7 +150,7 @@ class Locked extends Component {
componentWillUnmount() {
this.props.session.dispatcher.removeListener(WEBSOCKET_MESSAGE_TYPES.ALARM.DISARMED, this.disarmed);
}
render({}, { currentCode, error, wrongCode, tooManyRequests, waitTimeInMinute }) {
render({}, { currentCode, error, wrongCode, tooManyRequests, waitTimeInMinute, errorMessage, errorStatus }) {
return (
<div class={cx('container', style.lockedContainer)}>
<div class="row">
Expand All @@ -170,10 +177,15 @@ class Locked extends Component {
<Text id="locked.description" />
</p>
{error && (
<div class="alert alert-error">
<div class="alert alert-danger">
<Text id="locked.error" />
</div>
)}
{errorMessage && (
<div class="alert alert-danger">
{errorStatus} {errorMessage}
</div>
)}
{wrongCode && (
<div class="alert alert-warning">
<Text id="locked.wrongCodeError" />
Expand Down

0 comments on commit aabe53c

Please sign in to comment.