1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-26 05:03:33 +00:00
Files
browser/src/popup/app/services/state.service.ts
2018-01-06 22:13:48 -05:00

36 lines
777 B
TypeScript

import { Abstractions } from '@bitwarden/jslib';
class StateService {
private state: any = {};
constructor(private storageService: Abstractions.StorageService, private constantsService: any) {
}
async init() {
const iconsDisabled = await this.storageService.get<boolean>(this.constantsService.disableFaviconKey);
this.saveState('faviconEnabled', !iconsDisabled);
}
saveState(key: string, data: any) {
this.state[key] = data;
}
getState(key: string): any {
if (key in this.state) {
return this.state[key];
}
return null;
}
removeState(key: string) {
delete this.state[key];
}
purgeState() {
this.state = {};
}
}
export default StateService;