This commit is contained in:
Mo Bitar
2020-02-11 11:17:03 -06:00
parent 1497048c72
commit d91d141417
12 changed files with 253 additions and 349 deletions

View File

@@ -1,4 +1,4 @@
import { SFPredicate, CreateMaxPayloadFromAnyObject } from 'snjs';
import { SFPredicate, ContentTypes, CreateMaxPayloadFromAnyObject } from 'snjs';
export const PrefKeys = {
TagsPanelWidth: 'tagsPanelWidth',
@@ -33,24 +33,26 @@ export class PreferencesManager {
streamPreferences() {
this.application.streamItems({
contentType: 'SN|UserPreferences',
contentType: ContentTypes.UserPrefs,
stream: () => {
this.preferencesDidChange();
this.loadSingleton();
}
});
}
async loadSingleton() {
const contentType = 'SN|UserPreferences';
const contentType = ContentTypes.UserPrefs;
const predicate = new SFPredicate('content_type', '=', contentType);
this.userPreferences = await this.application.singletonManager.findOrCreateSingleton({
predicate: predicate,
createPayload: CreateMaxPayloadFromAnyObject({
object: {
content_type: contentType
content_type: contentType,
content: {}
}
})
});
this.preferencesDidChange();
}
preferencesDidChange() {