From b29c3eff6e7591aa953d6013db34168a670b3420 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 14 Jul 2025 12:53:11 +0300 Subject: [PATCH] refactor(views): prepare for supporting subtrees --- apps/client/src/entities/fnote.ts | 8 ++++++++ apps/client/src/widgets/view_widgets/table_view/index.ts | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.ts index b5d575ed9..15ba79c22 100644 --- a/apps/client/src/entities/fnote.ts +++ b/apps/client/src/entities/fnote.ts @@ -256,6 +256,14 @@ class FNote { return this.children; } + async getSubtreeNoteIds() { + let noteIds: (string | string[])[] = []; + for (const child of await this.getChildNotes()) { + noteIds.push(await child.getSubtreeNoteIds()); + } + return noteIds.flat(); + } + async getChildNotes() { return await this.froca.getNotes(this.children); } diff --git a/apps/client/src/widgets/view_widgets/table_view/index.ts b/apps/client/src/widgets/view_widgets/table_view/index.ts index 40d431ad0..023af3e42 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -263,7 +263,7 @@ export default class TableView extends ViewMode { this.#manageColumnUpdate(); } - if (loadResults.getBranchRows().some(branch => branch.parentNoteId === this.parentNote.noteId) + if (loadResults.getBranchRows().some(branch => branch.parentNoteId === this.parentNote.noteId || this.args.noteIds.includes(branch.parentNoteId ?? "")) || loadResults.getNoteIds().some(noteId => this.args.noteIds.includes(noteId) || loadResults.getAttributeRows().some(attr => this.args.noteIds.includes(attr.noteId!)))) { this.#manageRowsUpdate();