Skip to content

Build your personal knowledge base with Trilium Notes

WIP per-tab hoisting

zadamac636b6649ae
diff --git a/src/public/app/services/hoisted_note.js b/src/public/app/services/hoisted_note.js
index 5c668b2fb3..953e8ae31d 100644
--- a/src/public/app/services/hoisted_note.js
+++ b/src/public/app/services/hoisted_note.js
@@ -25,7 +25,7 @@ function isRootNode(node) {
|| node.data.noteId === getHoistedNoteId();
}
-async function checkNoteAccess(notePath) {
+async function checkNoteAccess(notePath, tabContext) {
// notePath argument can contain only noteId which is not good when hoisted since
// then we need to check the whole note path
const resolvedNotePath = await treeService.resolveNotePath(notePath);
@@ -35,11 +35,11 @@ async function checkNoteAccess(notePath) {
return false;
}
- const hoistedNoteId = getHoistedNoteId();
+ const hoistedNoteId = tabContext.hoistedNoteId;
if (hoistedNoteId !== 'root' && !resolvedNotePath.includes(hoistedNoteId)) {
const confirmDialog = await import('../dialogs/confirm.js');
-
+console.trace("HI!", hoistedNoteId, notePath);
if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) {
return false;
}
diff --git a/src/public/app/services/tab_context.js b/src/public/app/services/tab_context.js
index bfc280d01a..1bde9d523e 100644
--- a/src/public/app/services/tab_context.js
+++ b/src/public/app/services/tab_context.js
@@ -45,7 +45,7 @@ class TabContext extends Component {
return;
}
- if (await hoistedNoteService.checkNoteAccess(resolvedNotePath) === false) {
+ if (await hoistedNoteService.checkNoteAccess(resolvedNotePath, this) === false) {
return; // note is outside of hoisted subtree and user chose not to unhoist
}
diff --git a/src/routes/api/autocomplete.js b/src/routes/api/autocomplete.js
index 84f7ea7419..ecdea6d0c8 100644
--- a/src/routes/api/autocomplete.js
+++ b/src/routes/api/autocomplete.js
@@ -5,7 +5,7 @@ const searchService = require('../../services/search/services/search.js');
const repository = require('../../services/repository');
const log = require('../../services/log');
const utils = require('../../services/utils');
-const optionService = require('../../services/options');
+const cls = require('../../services/cls');
function getAutocomplete(req) {
const query = req.query.query.trim();
@@ -35,7 +35,7 @@ function getRecentNotes(activeNoteId) {
let extraCondition = '';
const params = [activeNoteId];
- const hoistedNoteId = optionService.getOption('hoistedNoteId');
+ const hoistedNoteId = cls.getHoistedNoteId();
if (hoistedNoteId !== 'root') {
extraCondition = `AND recent_notes.notePath LIKE ?`;
params.push(hoistedNoteId + '%');
diff --git a/src/routes/api/tree.js b/src/routes/api/tree.js
index f9f68b381a..4b6572b8f6 100644
--- a/src/routes/api/tree.js
+++ b/src/routes/api/tree.js
@@ -84,7 +84,7 @@ function getTree(req) {
)
SELECT noteId FROM treeWithDescendantsAscendantsAndTemplates`, [subTreeNoteId, subTreeNoteId]);
- noteIds.push(subTreeNoteId);console.log("noteIds", noteIds);
+ noteIds.push(subTreeNoteId);
return getNotesAndBranchesAndAttributes(noteIds);
}
diff --git a/src/services/note_cache/note_cache_service.js b/src/services/note_cache/note_cache_service.js
index 811a6f5939..cb1a797f4c 100644
--- a/src/services/note_cache/note_cache_service.js
+++ b/src/services/note_cache/note_cache_service.js
@@ -86,6 +86,10 @@ function getNoteTitle(childNoteId, parentNoteId) {
}
function getNoteTitleArrayForPath(notePathArray) {
+ if (notePathArray.length === 1 && notePathArray[0] === cls.getHoistedNoteId()) {
+ return [getNoteTitle(cls.getHoistedNoteId())];
+ }
+
const titles = [];
let parentNoteId = 'root';