This commit is contained in:
Mo Bitar
2020-02-09 12:07:18 -06:00
parent 046f6ca5b9
commit 1a87df0db8
18 changed files with 1151 additions and 1130 deletions

View File

@@ -1,33 +1,40 @@
import _ from 'lodash';
import { ContentTypes, StorageValueModes, EncryptionIntents } from 'snjs';
import { ContentTypes, StorageValueModes, EncryptionIntents, PureService } from 'snjs';
import { AppStateEvents } from '@/state';
const CACHED_THEMES_KEY = 'cachedThemes';
export class ThemeManager {
export class ThemeManager extends PureService {
/* @ngInject */
constructor(
application,
appState,
desktopManager,
) {
super();
this.application = application;
this.appState = appState;
this.desktopManager = desktopManager;
this.activeThemes = [];
this.registerObservers();
application.onReady(() => {
application.onStart(() => {
if (!desktopManager.isDesktop) {
this.activateCachedThemes();
}
});
appState.addObserver((eventName, data) => {
this.unsubState = appState.addObserver((eventName, data) => {
if (eventName === AppStateEvents.DesktopExtsReady) {
this.activateCachedThemes();
}
});
}
/** @override */
async deinit() {
super.deinit();
this.unsubState();
}
async activateCachedThemes() {
const cachedThemes = await this.getCachedThemes();
const writeToCache = false;