Skip to content

Commit

Permalink
feat: confirm navigating away when upgrade is in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Jun 22, 2020
1 parent f0a352e commit 1e00dc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/assets/javascripts/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?"
13 changes: 10 additions & 3 deletions app/assets/javascripts/views/footer/footer_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 1e00dc2

Please sign in to comment.