fix: delete autolock pref on passcode remove

This commit is contained in:
Mo Bitar
2020-09-24 15:52:03 -05:00
parent 94a82412bd
commit 6f9b669523
2 changed files with 15 additions and 1 deletions

View File

@@ -549,7 +549,9 @@ class AccountMenuCtrl extends PureViewCtrl<{}, AccountMenuState> {
confirmButtonStyle: 'danger' confirmButtonStyle: 'danger'
})) { })) {
await preventRefreshing(STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL, async () => { await preventRefreshing(STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL, async () => {
await this.application.getAutolockService().deleteAutolockPreference();
await this.application!.removePasscode(); await this.application!.removePasscode();
await this.reloadAutoLockInterval();
}); });
this.refreshEncryptionStatus(); this.refreshEncryptionStatus();
} }

View File

@@ -43,12 +43,16 @@ export class AutolockService extends ApplicationService {
deinit() { deinit() {
this.unsubState(); this.unsubState();
this.cancelAutoLockTimer();
if (this.pollFocusInterval) { if (this.pollFocusInterval) {
clearInterval(this.pollFocusInterval); clearInterval(this.pollFocusInterval);
} }
} }
private lockApplication() { private lockApplication() {
if (!this.application.hasPasscode()) {
throw Error('Attempting to lock application with no passcode');
}
this.application.lock(); 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 * 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. * not triggered on a typical window blur event but rather on tab changes.
@@ -133,7 +144,7 @@ export class AutolockService extends ApplicationService {
} }
async beginAutoLockTimer() { async beginAutoLockTimer() {
var interval = await this.getAutoLockInterval(); const interval = await this.getAutoLockInterval();
if (interval === LOCK_INTERVAL_NONE) { if (interval === LOCK_INTERVAL_NONE) {
return; return;
} }
@@ -160,5 +171,6 @@ export class AutolockService extends ApplicationService {
cancelAutoLockTimer() { cancelAutoLockTimer() {
clearTimeout(this.lockTimeout); clearTimeout(this.lockTimeout);
this.lockAfterDate = undefined; this.lockAfterDate = undefined;
this.lockTimeout = undefined;
} }
} }