mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-13 19:51:37 +01:00
move lock service interval to init
This commit is contained in:
parent
799c90af17
commit
e6fde2e92b
@ -10,13 +10,25 @@ import { PlatformUtilsService } from '../abstractions/platformUtils.service';
|
|||||||
import { StorageService } from '../abstractions/storage.service';
|
import { StorageService } from '../abstractions/storage.service';
|
||||||
|
|
||||||
export class LockService implements LockServiceAbstraction {
|
export class LockService implements LockServiceAbstraction {
|
||||||
|
private inited = false;
|
||||||
|
|
||||||
constructor(private cipherService: CipherService, private folderService: FolderService,
|
constructor(private cipherService: CipherService, private folderService: FolderService,
|
||||||
private collectionService: CollectionService, private cryptoService: CryptoService,
|
private collectionService: CollectionService, private cryptoService: CryptoService,
|
||||||
private platformUtilsService: PlatformUtilsService, private storageService: StorageService,
|
private platformUtilsService: PlatformUtilsService, private storageService: StorageService,
|
||||||
private messagingService: MessagingService, private lockedCallback: Function) {
|
private messagingService: MessagingService, private lockedCallback: () => Promise<void>) {
|
||||||
|
}
|
||||||
|
|
||||||
|
init(checkOnInterval: boolean) {
|
||||||
|
if (this.inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.inited = true;
|
||||||
|
if (checkOnInterval) {
|
||||||
this.checkLock();
|
this.checkLock();
|
||||||
setInterval(() => this.checkLock(), 10 * 1000); // check every 10 seconds
|
setInterval(() => this.checkLock(), 10 * 1000); // check every 10 seconds
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async checkLock(): Promise<void> {
|
async checkLock(): Promise<void> {
|
||||||
if (this.platformUtilsService.isViewOpen()) {
|
if (this.platformUtilsService.isViewOpen()) {
|
||||||
@ -60,7 +72,9 @@ export class LockService implements LockServiceAbstraction {
|
|||||||
this.cipherService.clearCache();
|
this.cipherService.clearCache();
|
||||||
this.collectionService.clearCache();
|
this.collectionService.clearCache();
|
||||||
this.messagingService.send('locked');
|
this.messagingService.send('locked');
|
||||||
this.lockedCallback();
|
if (this.lockedCallback != null) {
|
||||||
|
await this.lockedCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setLockOption(lockOption: number): Promise<void> {
|
async setLockOption(lockOption: number): Promise<void> {
|
||||||
|
Loading…
Reference in New Issue
Block a user