diff --git a/app/assets/javascripts/strings.ts b/app/assets/javascripts/strings.ts index c8a0279536b..98a31cb53e8 100644 --- a/app/assets/javascripts/strings.ts +++ b/app/assets/javascripts/strings.ts @@ -49,3 +49,7 @@ export function StringImportError(errorCount: number) { /** @password_change */ export const STRING_FAILED_PASSWORD_CHANGE = "There was an error re-encrypting your items. Your password was changed, but not all your items were properly re-encrypted and synced. You should try syncing again. If all else fails, you should restore your notes from backup."; + +export const STRING_CONFIRM_APP_QUIT_DURING_UPGRADE = + "The encryption upgrade is in progress. You may lose data if you quit the app. " + + "Are you sure you want to quit?" diff --git a/app/assets/javascripts/views/footer/footer_view.ts b/app/assets/javascripts/views/footer/footer_view.ts index a81d3d43f1e..e4d8c5bcdfd 100644 --- a/app/assets/javascripts/views/footer/footer_view.ts +++ b/app/assets/javascripts/views/footer/footer_view.ts @@ -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() {