mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
chore(react/collections/table): react to external data changes
This commit is contained in:
parent
9758632bf0
commit
3046cfd6ee
@ -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;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user