refactored access to options on frontend

This commit is contained in:
zadam
2020-02-05 22:08:45 +01:00
parent 786bbbc160
commit 42017fde5f
32 changed files with 267 additions and 311 deletions

View File

@@ -1,30 +1,16 @@
import optionsService from './options.js';
import server from "./server.js";
import options from './options.js';
import appContext from "./app_context.js";
import treeService from "./tree.js";
let hoistedNoteId = 'root';
optionsService.waitForOptions().then(options => {
hoistedNoteId = options.get('hoistedNoteId');
});
function getHoistedNoteNoPromise() {
return hoistedNoteId;
}
async function getHoistedNoteId() {
await optionsService.waitForOptions();
return hoistedNoteId;
function getHoistedNoteId() {
return options.get('hoistedNoteId');
}
async function setHoistedNoteId(noteId) {
hoistedNoteId = noteId;
await options.save('hoistedNoteId', noteId);
await server.put('options/hoistedNoteId/' + noteId);
appContext.trigger('hoistedNoteChanged', {hoistedNoteId});
// FIXME - just use option load event
appContext.trigger('hoistedNoteChanged', {noteId});
}
async function unhoist() {
@@ -69,7 +55,6 @@ async function checkNoteAccess(notePath) {
export default {
getHoistedNoteId,
getHoistedNoteNoPromise,
setHoistedNoteId,
unhoist,
isTopLevelNode,