ApplicationService integration

This commit is contained in:
Mo Bitar
2020-03-20 19:03:02 -05:00
parent 0ec0fd4872
commit 0ef1ce8ef1
9 changed files with 897 additions and 447 deletions

View File

@@ -1,4 +1,10 @@
import { ApplicationEvents, SNPredicate, ContentTypes, CreateMaxPayloadFromAnyObject } from 'snjs';
import {
ApplicationEvents,
SNPredicate,
ContentTypes,
CreateMaxPayloadFromAnyObject,
ApplicationService
} from 'snjs';
export const PrefKeys = {
TagsPanelWidth: 'tagsPanelWidth',
@@ -17,18 +23,21 @@ export const PrefKeys = {
NotesHideTags: 'hideTags'
};
export class PreferencesManager {
export class PreferencesManager extends ApplicationService {
/* @ngInject */
constructor(
appState,
application
) {
this.application = application;
this.appState = appState;
this.unsub = application.addSingleEventObserver(ApplicationEvents.Launched, () => {
this.streamPreferences();
this.loadSingleton();
});
super(application);
this.appState = appState;
}
/** @override */
onAppLaunch() {
super.onAppLaunch();
this.streamPreferences();
this.loadSingleton();
}
streamPreferences() {
@@ -61,7 +70,7 @@ export class PreferencesManager {
syncUserPreferences() {
if (this.userPreferences) {
this.application.saveItem({item: this.userPreferences});
this.application.saveItem({ item: this.userPreferences });
}
}