Skip to content

Build your personal knowledge base with Trilium Notes

fix(client/tree): toast not appearing when inserted via paste

Elian Doranf46203486810
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ab07ad1887..f2ecc8f329 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1777,10 +1777,9 @@
"shared-indicator-tooltip": "This note is shared publicly",
"shared-indicator-tooltip-with-url": "This note is shared publicly at: {{- url}}",
"subtree-hidden-tooltip": "{{count}} child notes that are hidden from the tree",
- "subtree-hidden-moved-title_one": "{{count}} note moved to {{title}}",
- "subtree-hidden-moved-title_other": "{{count}} notes moved to {{title}}",
- "subtree-hidden-moved-description-collection": "Items in this collection are managed by its views.",
- "subtree-hidden-moved-description-other": "Items in this note are intentionally hidden."
+ "subtree-hidden-moved-title": "Added to {{title}}",
+ "subtree-hidden-moved-description-collection": "This collection hides its child notes in the tree.",
+ "subtree-hidden-moved-description-other": "Child notes are hidden in the tree for this note."
},
"title_bar_buttons": {
"window-on-top": "Keep Window on Top"
diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.ts
index 34aa0548c2..f6af3c3743 100644
--- a/apps/client/src/widgets/note_tree.ts
+++ b/apps/client/src/widgets/note_tree.ts
@@ -555,19 +555,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
} else if (data.hitMode === "after") {
branchService.moveAfterBranch(selectedBranchIds, node.data.branchId);
} else if (data.hitMode === "over") {
- const targetNote = froca.getNoteFromCache(node.data.noteId);
- if (targetNote?.isLabelTruthy("subtreeHidden")) {
- toastService.showPersistent({
- id: `subtree-hidden-moved`,
- title: t("note_tree.subtree-hidden-moved-title", { count: selectedBranchIds.length, title: targetNote.title }),
- message: targetNote.type === "book"
- ? t("note_tree.subtree-hidden-moved-description-collection")
- : t("note_tree.subtree-hidden-moved-description-other"),
- icon: "bx bx-hide",
- timeout: 5_000,
- });
- }
-
branchService.moveToParentNote(selectedBranchIds, node.data.branchId);
} else {
throw new Error(`Unknown hitMode '${data.hitMode}'`);
@@ -773,12 +760,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
const parentNote = froca.getNoteFromCache(branch.parentNoteId);
if (parentNote?.isLabelTruthy("subtreeHidden")) {
- const parentNode = node.getParent();
- if (parentNode) {
- parentNode.setActive(true);
- }
node.remove();
- return;
+ return "removed-due-to-subtree-hidden";
}
const title = `${branch.prefix ? `${branch.prefix} - ` : ""}${note.title}`;
@@ -1402,11 +1385,30 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
});
// for some reason, node update cannot be in the batchUpdate() block (node is not re-rendered)
+ let removedFromSubtreeParent: Fancytree.FancytreeNode | null = null;
for (const noteId of refreshCtx.noteIdsToUpdate) {
for (const node of this.getNodesByNoteId(noteId)) {
- await this.updateNode(node);
+ const parent = node.parent;
+ const result = await this.updateNode(node);
+ if (result === "removed-due-to-subtree-hidden") {
+ removedFromSubtreeParent = parent;
+ }
}
}
+
+ if (removedFromSubtreeParent) {
+ removedFromSubtreeParent.setActive(true, { noEvents: true });
+ const targetNote = froca.getNoteFromCache(removedFromSubtreeParent.data.noteId || "");
+ toastService.showPersistent({
+ id: `subtree-hidden-moved`,
+ title: t("note_tree.subtree-hidden-moved-title", { title: targetNote?.title }),
+ message: targetNote?.type === "book"
+ ? t("note_tree.subtree-hidden-moved-description-collection")
+ : t("note_tree.subtree-hidden-moved-description-other"),
+ icon: "bx bx-hide",
+ timeout: 5_000,
+ });
+ }
}
async #setActiveNode(activeNotePath: string | null, activeNodeFocused: boolean, movedActiveNode: Fancytree.FancytreeNode | null, parentsOfAddedNodes: Fancytree.FancytreeNode[]) {