server-ts: Port services/hoisted_note

This commit is contained in:
Elian Doran
2024-02-18 00:22:46 +02:00
parent 5d683721b1
commit 1010d11827
5 changed files with 8 additions and 8 deletions

View File

@@ -0,0 +1,40 @@
import cls = require('./cls');
import becca = require('../becca/becca');
function getHoistedNoteId() {
return cls.getHoistedNoteId();
}
function isHoistedInHiddenSubtree() {
const hoistedNoteId = getHoistedNoteId();
if (hoistedNoteId === 'root') {
return false;
} else if (hoistedNoteId === '_hidden') {
return true;
}
const hoistedNote = becca.getNote(hoistedNoteId);
if (!hoistedNote) {
throw new Error(`Cannot find hoisted note '${hoistedNoteId}'`);
}
return hoistedNote.isHiddenCompletely();
}
function getWorkspaceNote() {
const hoistedNote = becca.getNote(cls.getHoistedNoteId());
if (hoistedNote && (hoistedNote.isRoot() || hoistedNote.hasLabel('workspace'))) {
return hoistedNote;
} else {
return becca.getRoot();
}
}
export = {
getHoistedNoteId,
getWorkspaceNote,
isHoistedInHiddenSubtree
};