Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(react/collections/table): react to external data changes
Elian Doran3046cfd6eea9
diff --git a/apps/client/src/widgets/collections/table/index.tsx b/apps/client/src/widgets/collections/table/index.tsxindex 7d7048a553..5ab96ee6e3 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 | undefuseEffect(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.tsindex af92b86d31..22ef0e7e48 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.tsindex 2011a7456e..d0684b3172 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<StateInfo> {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;