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

Keep full screen mode after redirecting to locked/dashboard #1931

Merged
merged 1 commit into from Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion front/src/actions/main.js
Expand Up @@ -84,7 +84,7 @@ function createActions(store) {
const gatewayErrorMessage = get(e, 'response.data.error_message');
const errorMessageOtherFormat = get(e, 'response.data.message');
if (status === 401 && errorMessageOtherFormat === 'TABLET_IS_LOCKED') {
route('/locked');
route(`/locked${window.location.search}`);
} else if (status === 401) {
state.session.reset();
actions.redirectToLogin();
Expand Down
8 changes: 6 additions & 2 deletions front/src/routes/dashboard/index.js
Expand Up @@ -155,19 +155,23 @@ class Dashboard extends Component {
this.props.setFullScreen(isFullScreen);
};

redirectToLocked = () => {
route(`/locked${window.location.search}`);
};

alarmArmed = async () => {
// Check server side if we are in tablet mode
try {
const currentSession = await this.props.httpClient.get('/api/v1/session/tablet_mode');
if (currentSession.tablet_mode) {
route('/locked');
this.redirectToLocked();
}
} catch (e) {
console.error(e);
const status = get(e, 'response.status');
const errorMessageOtherFormat = get(e, 'response.data.message');
if (status === 401 && errorMessageOtherFormat === 'TABLET_IS_LOCKED') {
route('/locked');
this.redirectToLocked();
}
}
};
Expand Down
8 changes: 6 additions & 2 deletions front/src/routes/locked/index.js
Expand Up @@ -73,15 +73,19 @@ class Locked extends Component {
return { ...prevState, currentCode: prevState.currentCode + letter };
});
};
redirectToDashboard = () => {
route(`/dashboard${window.location.search}`);
};
init = async () => {
try {
// We make a dumb request just to verify if our token is valid
await this.props.httpClient.post('/api/v1/access_token', {
refresh_token: this.props.session.getRefreshToken(),
scope: ['dashboard:write']
});

// if this resolves, we redirect to dashboard
route('/dashboard');
this.redirectToDashboard();
} catch (e) {
this.props.httpClient.setApiScopes(['alarm:write']);
await this.props.httpClient.refreshAccessToken();
Expand All @@ -101,7 +105,7 @@ class Locked extends Component {
if (event.house === houseSelector) {
this.props.httpClient.resetApiScopes();
await this.props.httpClient.refreshAccessToken();
route('/dashboard');
this.redirectToDashboard();
}
} catch (e) {
console.error(e);
Expand Down