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

@@ -15,8 +15,9 @@ export class NativeExtManager {
this.resolveExtensionsManager();
this.resolveBatchManager();
application.onReady(() => {
this.initialize();
application.onUnlock(() => {
this.resolveExtensionsManager();
this.resolveBatchManager();
});
}
@@ -24,11 +25,6 @@ export class NativeExtManager {
return this.systemExtensions.includes(extension.uuid);
}
async initialize() {
this.resolveExtensionsManager();
this.resolveBatchManager();
}
extensionsManagerTemplatePayload() {
const url = window._extensions_manager_location;
if (!url) {

View File

@@ -1,5 +1,4 @@
import { SFPredicate, CreateMaxPayloadFromAnyObject } from 'snjs';
import { AppStateEvents } from '../state';
export const PrefKeys = {
TagsPanelWidth: 'tagsPanelWidth',
@@ -26,16 +25,12 @@ export class PreferencesManager {
) {
this.application = application;
this.appState = appState;
application.onReady(() => {
this.initialize();
application.onUnlock(() => {
this.streamPreferences();
this.loadSingleton();
});
}
async initialize() {
this.streamPreferences();
await this.loadSingleton();
}
streamPreferences() {
this.application.streamItems({
contentType: 'SN|UserPreferences',

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;