From 3046cfd6eea9cc11b0b4c07c76cc9ef961929eae Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Tue, 9 Sep 2025 19:34:22 +0300 Subject: [PATCH] chore(react/collections/table): react to external data changes --- apps/client/src/widgets/collections/table/index.tsx | 11 ++++++++++- .../src/widgets/collections/table/row_editing.ts | 1 - .../src/widgets/view_widgets/table_view/index.ts | 10 ---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/client/src/widgets/collections/table/index.tsx b/apps/client/src/widgets/collections/table/index.tsx index 7d7048a55..5ab96ee6e 100644 --- a/apps/client/src/widgets/collections/table/index.tsx +++ b/apps/client/src/widgets/collections/table/index.tsx @@ -135,13 +135,22 @@ function useData(note: FNote, noteIds: string[], viewConfig: TableConfig | undef useEffect(refresh, [ note, noteIds, maxDepth, movableRows ]); - // React to column changes. useTriliumEvent("entitiesReloaded", ({ loadResults}) => { + // React to column changes. if (loadResults.getAttributeRows().find(attr => attr.type === "label" && (attr.name?.startsWith("label:") || attr.name?.startsWith("relation:")) && attributes.isAffecting(attr, note))) { refresh(); + return; + } + + // React to external row updates. + if (loadResults.getBranchRows().some(branch => branch.parentNoteId === note.noteId || noteIds.includes(branch.parentNoteId ?? "")) + || loadResults.getNoteIds().some(noteId => noteIds.includes(noteId)) + || loadResults.getAttributeRows().some(attr => noteIds.includes(attr.noteId!))) { + refresh(); + return; } }); diff --git a/apps/client/src/widgets/collections/table/row_editing.ts b/apps/client/src/widgets/collections/table/row_editing.ts index af92b86d3..22ef0e7e4 100644 --- a/apps/client/src/widgets/collections/table/row_editing.ts +++ b/apps/client/src/widgets/collections/table/row_editing.ts @@ -6,7 +6,6 @@ import { RefObject } from "preact"; import { setAttribute, setLabel } from "../../../services/attributes"; import froca from "../../../services/froca"; import server from "../../../services/server"; -import FNote from "../../../entities/fnote"; import branches from "../../../services/branches"; import AttributeDetailWidget from "../../attribute_widgets/attribute_detail"; 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 2011a7456..d0684b317 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -60,16 +60,6 @@ export default class TableView extends ViewMode { setupContextMenu(this.api, this.parentNote); } - async onEntitiesReloaded({ loadResults }: EventData<"entitiesReloaded">) { - if (loadResults.getBranchRows().some(branch => branch.parentNoteId === this.parentNote.noteId || this.noteIds.includes(branch.parentNoteId ?? "")) - || loadResults.getNoteIds().some(noteId => this.noteIds.includes(noteId)) - || loadResults.getAttributeRows().some(attr => this.noteIds.includes(attr.noteId!))) { - return await this.#manageRowsUpdate(); - } - - return false; - } - #manageColumnUpdate() { if (!this.api) { return;