From 8ad779be66f80284bbcfafc381191e7d398142ad Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 10 Jan 2026 12:26:08 +0200 Subject: [PATCH] fix(client/load_results): component ID not preserved for attributes & branches --- apps/client/src/services/load_results.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/client/src/services/load_results.ts b/apps/client/src/services/load_results.ts index 899560de4..5b6589c65 100644 --- a/apps/client/src/services/load_results.ts +++ b/apps/client/src/services/load_results.ts @@ -1,4 +1,5 @@ import type { AttachmentRow, EtapiTokenRow, NoteType, OptionNames } from "@triliumnext/commons"; + import type { AttributeType } from "../entities/fattribute.js"; import type { EntityChange } from "../server_types.js"; @@ -131,11 +132,19 @@ export default class LoadResults { } addBranch(branchId: string, componentId: string) { + console.log("Got branch with ", branchId, componentId); this.branchRows.push({ branchId, componentId }); } getBranchRows() { - return this.branchRows.map((row) => this.getEntityRow("branches", row.branchId)).filter((branch) => !!branch); + return this.branchRows.map((row) => { + const branch = this.getEntityRow("branches", row.branchId); + if (branch) { + // Merge the componentId from the tracked row with the entity data + return { ...branch, componentId: row.componentId }; + } + return null; + }).filter((branch) => !!branch) as BranchRow[]; } addNoteReordering(parentNoteId: string, componentId: string) { @@ -153,7 +162,14 @@ export default class LoadResults { getAttributeRows(componentId = "none"): AttributeRow[] { return this.attributeRows .filter((row) => row.componentId !== componentId) - .map((row) => this.getEntityRow("attributes", row.attributeId)) + .map((row) => { + const attr = this.getEntityRow("attributes", row.attributeId); + if (attr) { + // Merge the componentId from the tracked row with the entity data + return { ...attr, componentId: row.componentId }; + } + return null; + }) .filter((attr) => !!attr) as AttributeRow[]; }