mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 00:35:50 +01:00
server-ts: Port services/hoisted_note
This commit is contained in:
40
src/services/hoisted_note.ts
Normal file
40
src/services/hoisted_note.ts
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user