1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-26 17:08:33 +01:00

convert more service abstractions

This commit is contained in:
Kyle Spearrin 2018-02-10 10:53:07 -05:00
parent 8d4799a0a2
commit 6c3f0a538f
3 changed files with 13 additions and 14 deletions

View File

@ -1,4 +1,4 @@
export interface LockService {
checkLock(): Promise<void>;
lock(): Promise<void>;
export abstract class LockService {
checkLock: () => Promise<void>;
lock: () => Promise<void>;
}

View File

@ -1,5 +1,5 @@
export interface StorageService {
get<T>(key: string): Promise<T>;
save(key: string, obj: any): Promise<any>;
remove(key: string): Promise<any>;
export abstract class StorageService {
get: <T>(key: string) => Promise<T>;
save: (key: string, obj: any) => Promise<any>;
remove: (key: string) => Promise<any>;
}

View File

@ -4,16 +4,16 @@ import { CipherService } from '../abstractions/cipher.service';
import { CollectionService } from '../abstractions/collection.service';
import { CryptoService } from '../abstractions/crypto.service';
import { FolderService } from '../abstractions/folder.service';
import { LockService as LockServiceInterface } from '../abstractions/lock.service';
import { LockService as LockServiceAbstraction } from '../abstractions/lock.service';
import { MessagingService } from '../abstractions/messaging.service';
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
import { StorageService } from '../abstractions/storage.service';
export class LockService implements LockServiceInterface {
export class LockService implements LockServiceAbstraction {
constructor(private cipherService: CipherService, private folderService: FolderService,
private collectionService: CollectionService, private cryptoService: CryptoService,
private platformUtilsService: PlatformUtilsService,
private storageService: StorageService,
private setIcon: Function, private refreshBadgeAndMenu: Function) {
private platformUtilsService: PlatformUtilsService, private storageService: StorageService,
private messagingService: MessagingService) {
this.checkLock();
setInterval(() => this.checkLock(), 10 * 1000); // check every 10 seconds
}
@ -54,12 +54,11 @@ export class LockService implements LockServiceInterface {
this.cryptoService.clearOrgKeys(true),
this.cryptoService.clearPrivateKey(true),
this.cryptoService.clearEncKey(true),
this.setIcon(),
this.refreshBadgeAndMenu(),
]);
this.folderService.clearCache();
this.cipherService.clearCache();
this.collectionService.clearCache();
this.messagingService.send('locked');
}
}