From a08bc79ae4a35af75e2224b0b83cc8a9bd8dc889 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 12 Sep 2025 17:20:22 +0300 Subject: [PATCH] feat(collections/board): add option to archive note --- apps/client/src/entities/fnote.ts | 4 +++- apps/client/src/translations/en/translation.json | 1 + apps/client/src/widgets/collections/NoteList.tsx | 4 +++- apps/client/src/widgets/collections/board/context_menu.ts | 6 ++++++ apps/client/src/widgets/collections/board/data.ts | 4 +--- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.ts index b80e8e3fb..354a2f213 100644 --- a/apps/client/src/entities/fnote.ts +++ b/apps/client/src/entities/fnote.ts @@ -259,6 +259,8 @@ export default class FNote { async getSubtreeNoteIds() { let noteIds: (string | string[])[] = []; for (const child of await this.getChildNotes()) { + if (child.isArchived) continue; + noteIds.push(child.noteId); noteIds.push(await child.getSubtreeNoteIds()); } @@ -267,7 +269,7 @@ export default class FNote { async getSubtreeNotes() { const noteIds = await this.getSubtreeNoteIds(); - return this.froca.getNotes(noteIds); + return (await this.froca.getNotes(noteIds)).filter(note => !note.isArchived) } async getChildNotes() { diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 7e0932616..bba8036bf 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1994,6 +1994,7 @@ }, "board_view": { "delete-note": "Delete Note", + "archive-note": "Archive Note", "move-to": "Move to", "insert-above": "Insert above", "insert-below": "Insert below", diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx index fe62d0254..1d642c3b2 100644 --- a/apps/client/src/widgets/collections/NoteList.tsx +++ b/apps/client/src/widgets/collections/NoteList.tsx @@ -129,7 +129,9 @@ function useNoteIds(note: FNote | null | undefined, viewType: ViewTypeOptions | useTriliumEvent("entitiesReloaded", ({ loadResults }) => { if (note && loadResults.getBranchRows().some(branch => branch.parentNoteId === note.noteId - || noteIds.includes(branch.parentNoteId ?? ""))) { + || noteIds.includes(branch.parentNoteId ?? "")) + || loadResults.getAttributeRows().some(attr => attr.name === "archived" && attr.noteId && noteIds.includes(attr.noteId)) + ) { refreshNoteIds(); } }) diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts index 303db332a..a2489fcf2 100644 --- a/apps/client/src/widgets/collections/board/context_menu.ts +++ b/apps/client/src/widgets/collections/board/context_menu.ts @@ -1,5 +1,6 @@ import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu"; import link_context_menu from "../../../menus/link_context_menu"; +import attributes from "../../../services/attributes"; import branches from "../../../services/branches"; import dialog from "../../../services/dialog"; import { t } from "../../../services/i18n"; @@ -65,6 +66,11 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, noteId: s title: t("board_view.delete-note"), uiIcon: "bx bx-trash", handler: () => branches.deleteNotes([ branchId ], false, false) + }, + { + title: t("board_view.archive-note"), + uiIcon: "bx bx-archive", + handler: () => attributes.addLabel(noteId, "archived") } ], selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, noteId), diff --git a/apps/client/src/widgets/collections/board/data.ts b/apps/client/src/widgets/collections/board/data.ts index 2a59e82b7..9f55b26b5 100644 --- a/apps/client/src/widgets/collections/board/data.ts +++ b/apps/client/src/widgets/collections/board/data.ts @@ -64,9 +64,7 @@ export async function getBoardData(parentNote: FNote, groupByColumn: string, per async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string) { for (const branch of branches) { const note = await branch.getNote(); - if (!note) { - continue; - } + if (!note || note.isArchived) continue; if (note.hasChildren()) { await recursiveGroupBy(note.getChildBranches(), byColumn, groupByColumn);