Skip to content

Build your personal knowledge base with Trilium Notes

fix activating notes in the hidden subtree

zadam4f1f632a7dec
diff --git a/src/public/app/services/hoisted_note.js b/src/public/app/services/hoisted_note.js
index 1e960c39e5..b188d27a0d 100644
--- a/src/public/app/services/hoisted_note.js
+++ b/src/public/app/services/hoisted_note.js
@@ -1,6 +1,7 @@
import appContext from "./app_context.js";
import treeService from "./tree.js";
import dialogService from "../widgets/dialog.js";
+import froca from "./froca.js";
function getHoistedNoteId() {
const activeNoteContext = appContext.tabManager.getActiveContext();
@@ -26,6 +27,19 @@ function isHoistedNode(node) {
|| node.data.noteId === getHoistedNoteId();
}
+async function isHoistedInHiddenSubtree() {
+ const hoistedNoteId = getHoistedNoteId();
+
+ if (hoistedNoteId === 'root') {
+ return false;
+ }
+
+ const hoistedNote = await froca.getNote(hoistedNoteId);
+ const hoistedNotePath = treeService.getSomeNotePath(hoistedNote);
+
+ return treeService.isNotePathInHiddenSubtree(hoistedNotePath);
+}
+
async function checkNoteAccess(notePath, noteContext) {
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
@@ -53,5 +67,6 @@ export default {
unhoist,
isTopLevelNode,
isHoistedNode,
- checkNoteAccess
+ checkNoteAccess,
+ isHoistedInHiddenSubtree
}
diff --git a/src/public/app/services/tree.js b/src/public/app/services/tree.js
index b4b2eb0380..6657c864c8 100644
--- a/src/public/app/services/tree.js
+++ b/src/public/app/services/tree.js
@@ -314,6 +314,10 @@ function parseNotePath(notePath) {
return noteIds;
}
+function isNotePathInHiddenSubtree(notePath) {
+ return notePath?.includes("root/hidden");
+}
+
export default {
resolveNotePath,
resolveNotePathToSegments,
@@ -328,5 +332,6 @@ export default {
getNotePathTitle,
getNoteTitleWithPathAsSuffix,
getHashValueFromAddress,
- parseNotePath
+ parseNotePath,
+ isNotePathInHiddenSubtree
};
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 032eeea385..63aefc8d93 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -964,7 +964,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
if (this.noteContext
&& this.noteContext.notePath
&& !this.noteContext.note?.isDeleted
- && !this.noteContext.notePath.includes("root/hidden")
+ && (!treeService.isNotePathInHiddenSubtree(this.noteContext.notePath) || await hoistedNoteService.isHoistedInHiddenSubtree())
) {
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);
@@ -1058,7 +1058,9 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
const noteIdsToReload = new Set();
for (const ecAttr of loadResults.getAttributes()) {
- if (ecAttr.type === 'label' && ['iconClass', 'cssClass', 'workspace', 'workspaceIconClass', 'archived', 'color'].includes(ecAttr.name)) {
+ const dirtyingLabels = ['iconClass', 'cssClass', 'workspace', 'workspaceIconClass', 'archived', 'color'];
+
+ if (ecAttr.type === 'label' && dirtyingLabels.includes(ecAttr.name)) {
if (ecAttr.isInheritable) {
noteIdsToReload.add(ecAttr.noteId);
}
@@ -1169,7 +1171,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
let node = await this.expandToNote(activeNotePath, false);
if (node && node.data.noteId !== activeNoteId) {
- // if the active note has been moved elsewhere then it won't be found by the path
+ // if the active note has been moved elsewhere then it won't be found by the path,
// so we switch to the alternative of trying to find it by noteId
const notesById = this.getNodesByNoteId(activeNoteId);
@@ -1186,7 +1188,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
await node.setActive(true, {noEvents: true, noFocus: !activeNodeFocused});
}
else {
- // this is used when original note has been deleted and we want to move the focus to the note above/below
+ // this is used when original note has been deleted, and we want to move the focus to the note above/below
node = await this.expandToNote(nextNotePath, false);
if (node) {