From 6f9b669523d06996b8011361fb96614be8274a06 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Thu, 24 Sep 2020 15:52:03 -0500 Subject: [PATCH] fix: delete autolock pref on passcode remove --- .../javascripts/directives/views/accountMenu.ts | 2 ++ .../javascripts/services/autolock_service.ts | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/directives/views/accountMenu.ts b/app/assets/javascripts/directives/views/accountMenu.ts index 8d9e334ab..bcd957214 100644 --- a/app/assets/javascripts/directives/views/accountMenu.ts +++ b/app/assets/javascripts/directives/views/accountMenu.ts @@ -549,7 +549,9 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> { confirmButtonStyle: 'danger' })) { await preventRefreshing(STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL, async () => { + await this.application.getAutolockService().deleteAutolockPreference(); await this.application!.removePasscode(); + await this.reloadAutoLockInterval(); }); this.refreshEncryptionStatus(); } diff --git a/app/assets/javascripts/services/autolock_service.ts b/app/assets/javascripts/services/autolock_service.ts index 22e3d1d8f..fc1692ad0 100644 --- a/app/assets/javascripts/services/autolock_service.ts +++ b/app/assets/javascripts/services/autolock_service.ts @@ -43,12 +43,16 @@ export class AutolockService extends ApplicationService { deinit() { this.unsubState(); + this.cancelAutoLockTimer(); if (this.pollFocusInterval) { clearInterval(this.pollFocusInterval); } } private lockApplication() { + if (!this.application.hasPasscode()) { + throw Error('Attempting to lock application with no passcode'); + } this.application.lock(); } @@ -70,6 +74,13 @@ export class AutolockService extends ApplicationService { } } + async deleteAutolockPreference() { + await this.application!.removeValue( + STORAGE_KEY_AUTOLOCK_INTERVAL + ); + this.cancelAutoLockTimer(); + } + /** * Verify document is in focus every so often as visibilitychange event is * not triggered on a typical window blur event but rather on tab changes. @@ -133,7 +144,7 @@ export class AutolockService extends ApplicationService { } async beginAutoLockTimer() { - var interval = await this.getAutoLockInterval(); + const interval = await this.getAutoLockInterval(); if (interval === LOCK_INTERVAL_NONE) { return; } @@ -160,5 +171,6 @@ export class AutolockService extends ApplicationService { cancelAutoLockTimer() { clearTimeout(this.lockTimeout); this.lockAfterDate = undefined; + this.lockTimeout = undefined; } }