mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
40 lines
969 B
TypeScript
40 lines
969 B
TypeScript
import { ConstantsService } from 'jslib/services/constants.service';
|
|
|
|
import { StorageService } from 'jslib/abstractions/storage.service';
|
|
|
|
export class StateService {
|
|
private state: any = {};
|
|
|
|
constructor(private storageService: StorageService, private constantsService: ConstantsService) {
|
|
}
|
|
|
|
async init() {
|
|
if (this.storageService != null) {
|
|
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 = {};
|
|
}
|
|
}
|
|
|
|
StateService.$inject = ['storageService', 'constantsService'];
|