Notes/src/public/javascripts/services/hoisted_note.js

33 lines
623 B
JavaScript
Raw Normal View History

2018-12-11 21:53:56 +01:00
import optionsInit from './options_init.js';
import server from "./server.js";
2018-12-12 20:39:56 +01:00
import tree from "./tree.js";
2018-12-11 21:53:56 +01:00
let hoistedNoteId;
optionsInit.optionsReady.then(options => {
hoistedNoteId = options['hoistedNoteId'];
});
async function getHoistedNoteId() {
await optionsInit.optionsReady;
return hoistedNoteId;
}
async function setHoistedNoteId(noteId) {
hoistedNoteId = noteId;
await server.put('options/hoistedNoteId/' + noteId);
2018-12-12 20:39:56 +01:00
await tree.reload();
2018-12-11 21:53:56 +01:00
}
2018-12-15 20:29:08 +01:00
async function unhoist() {
await setHoistedNoteId('root');
}
2018-12-11 21:53:56 +01:00
export default {
getHoistedNoteId,
2018-12-15 20:29:08 +01:00
setHoistedNoteId,
unhoist
2018-12-11 21:53:56 +01:00
}