1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 22:33:35 +00:00

use utils for lock options settings

This commit is contained in:
Kyle Spearrin
2017-11-29 10:19:21 -05:00
parent b6a5180a6a
commit ab1a918326

View File

@@ -32,10 +32,9 @@ export class SettingsController {
}, 500); }, 500);
this.showOnLocked = !utilsService.isFirefox() && !utilsService.isEdge(); this.showOnLocked = !utilsService.isFirefox() && !utilsService.isEdge();
this.utilsService.getObjFromStorage(constantsService.lockOptionKey).then((lockOption: number) => {
chrome.storage.local.get(constantsService.lockOptionKey, (obj: any) => { if (lockOption != null) {
if (obj && (obj[constantsService.lockOptionKey] || obj[constantsService.lockOptionKey] === 0)) { let option = lockOption.toString();
let option = obj[constantsService.lockOptionKey].toString();
if (option === '-2' && !this.showOnLocked) { if (option === '-2' && !this.showOnLocked) {
option = '-1'; option = '-1';
} }
@@ -47,31 +46,26 @@ export class SettingsController {
} }
changeLockOption() { changeLockOption() {
const obj: any = {}; const option = this.lockOption && this.lockOption !== '' ? parseInt(this.lockOption, 10) : null;
obj[this.constantsService.lockOptionKey] = null; this.utilsService.saveObjToStorage(this.constantsService.lockOptionKey, option).then(() => {
if (this.lockOption && this.lockOption !== '') { return this.cryptoService.getKeyHash();
obj[this.constantsService.lockOptionKey] = parseInt(this.lockOption, 10); }).then((keyHash) => {
} if (keyHash) {
this.cryptoService.toggleKey();
chrome.storage.local.set(obj, () => { } else {
this.cryptoService.getKeyHash().then((keyHash) => { this.SweetAlert.swal({
if (keyHash) { title: this.i18nService.loggingOut,
this.cryptoService.toggleKey(); text: this.i18nService.loggingOutConfirmation,
} else { showCancelButton: true,
this.SweetAlert.swal({ confirmButtonText: this.i18nService.yes,
title: this.i18nService.loggingOut, cancelButtonText: this.i18nService.cancel,
text: this.i18nService.loggingOutConfirmation, }, (confirmed: boolean) => {
showCancelButton: true, if (confirmed) {
confirmButtonText: this.i18nService.yes, this.cryptoService.toggleKey();
cancelButtonText: this.i18nService.cancel, chrome.runtime.sendMessage({ command: 'logout' });
}, (confirmed: boolean) => { }
if (confirmed) { });
this.cryptoService.toggleKey(); }
chrome.runtime.sendMessage({ command: 'logout' });
}
});
}
});
}); });
} }