feat: confirm navigating away when upgrade is in progress

This commit is contained in:
Baptiste Grob
2020-06-22 17:52:48 +02:00
parent f0a352edc5
commit 1e00dc2be8
2 changed files with 14 additions and 3 deletions

View File

@@ -16,7 +16,8 @@ import template from './footer-view.pug';
import { AppStateEvent, EventSource } from '@/ui_models/app_state';
import {
STRING_GENERIC_SYNC_ERROR,
STRING_NEW_UPDATE_READY
STRING_NEW_UPDATE_READY,
STRING_CONFIRM_APP_QUIT_DURING_UPGRADE
} from '@/strings';
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
import { ComponentMutator } from '@node_modules/snjs/dist/@types/models';
@@ -298,8 +299,14 @@ class FooterViewCtrl extends PureViewCtrl {
this.offline = this.application!.noAccount();
}
openSecurityUpdate() {
this.application!.performProtocolUpgrade();
async openSecurityUpdate() {
const onBeforeUnload = window.onbeforeunload;
try {
window.onbeforeunload = () => STRING_CONFIRM_APP_QUIT_DURING_UPGRADE;
await this.application!.performProtocolUpgrade();
} finally {
window.onbeforeunload = onBeforeUnload;
}
}
findErrors() {