fix(views/table): error when adding a new column

This commit is contained in:
Elian Doran 2025-06-28 16:51:24 +03:00
parent ada39cd3c7
commit 50ebcd552c
No known key found for this signature in database

View File

@ -201,7 +201,7 @@ export default class TableView extends ViewMode<StateInfo> {
} }
} }
async onEntitiesReloaded({ loadResults }: EventData<"entitiesReloaded">): boolean | void { onEntitiesReloaded({ loadResults }: EventData<"entitiesReloaded">): boolean | void {
if (!this.api) { if (!this.api) {
return; return;
} }
@ -211,19 +211,27 @@ export default class TableView extends ViewMode<StateInfo> {
attr.type === "label" && attr.type === "label" &&
attr.name?.startsWith("label:") && attr.name?.startsWith("label:") &&
attributes.isAffecting(attr, this.parentNote))) { attributes.isAffecting(attr, this.parentNote))) {
const info = getPromotedAttributeInformation(this.parentNote); this.#manageColumnUpdate();
const columnDefs = buildColumnDefinitions(info);
this.api.setColumns(columnDefs)
} }
if (loadResults.getBranchRows().some(branch => branch.parentNoteId === this.parentNote.noteId)) { if (loadResults.getBranchRows().some(branch => branch.parentNoteId === this.parentNote.noteId)) {
const notes = await froca.getNotes(this.args.noteIds); this.#manageRowsUpdate();
const info = getPromotedAttributeInformation(this.parentNote);
this.api.setData(await buildRowDefinitions(this.parentNote, notes, info));
} }
return false; return false;
} }
#manageColumnUpdate() {
const info = getPromotedAttributeInformation(this.parentNote);
const columnDefs = buildColumnDefinitions(info);
this.api.setColumns(columnDefs);
}
async #manageRowsUpdate() {
const notes = await froca.getNotes(this.args.noteIds);
const info = getPromotedAttributeInformation(this.parentNote);
this.api.setData(await buildRowDefinitions(this.parentNote, notes, info));
}
} }