mirror of
https://github.com/bitwarden/browser
synced 2026-01-20 01:13:48 +00:00
lock reload
This commit is contained in:
@@ -14,6 +14,7 @@ export class LockService implements LockServiceAbstraction {
|
||||
pinLocked = false;
|
||||
|
||||
private inited = false;
|
||||
private reloadInterval: any = null;
|
||||
|
||||
constructor(private cipherService: CipherService, private folderService: FolderService,
|
||||
private collectionService: CollectionService, private cryptoService: CryptoService,
|
||||
@@ -117,4 +118,31 @@ export class LockService implements LockServiceAbstraction {
|
||||
clear(): Promise<any> {
|
||||
return this.storageService.remove(ConstantsService.protectedPin);
|
||||
}
|
||||
|
||||
startLockReload(): void {
|
||||
if (this.pinLocked || this.reloadInterval != null) {
|
||||
return;
|
||||
}
|
||||
this.reloadInterval = setInterval(async () => {
|
||||
let doRefresh = false;
|
||||
const lastActive = await this.storageService.get<number>(ConstantsService.lastActiveKey);
|
||||
if (lastActive != null) {
|
||||
const diffSeconds = (new Date()).getTime() - lastActive;
|
||||
// Don't refresh if they are still active in the window
|
||||
doRefresh = diffSeconds >= 5000;
|
||||
}
|
||||
if (doRefresh) {
|
||||
clearInterval(this.reloadInterval);
|
||||
this.reloadInterval = null;
|
||||
this.messagingService.send('reloadProcess');
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
cancelLockReload(): void {
|
||||
if (this.reloadInterval != null) {
|
||||
clearInterval(this.reloadInterval);
|
||||
this.reloadInterval = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user