From 0de527dfd8249894d01d1236504c3eeee1eec682 Mon Sep 17 00:00:00 2001 From: Guilhem Date: Tue, 11 Nov 2025 10:57:29 +0100 Subject: [PATCH] fined grained graph rendering for notes --- .../src/lib/components/graph/FlowGraphV2.svelte | 2 +- .../lib/components/graph/noteManager.svelte.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/graph/FlowGraphV2.svelte b/frontend/src/lib/components/graph/FlowGraphV2.svelte index 11c6f941f9..e02421e502 100644 --- a/frontend/src/lib/components/graph/FlowGraphV2.svelte +++ b/frontend/src/lib/components/graph/FlowGraphV2.svelte @@ -620,7 +620,7 @@ }) $effect(() => { - ;[graph, allowSimplifiedPoll, $showAssets, notes] + ;[graph, allowSimplifiedPoll, $showAssets, noteManager.renderCount] untrack(() => updateStores()) }) diff --git a/frontend/src/lib/components/graph/noteManager.svelte.ts b/frontend/src/lib/components/graph/noteManager.svelte.ts index c08db0a065..90dadb993b 100644 --- a/frontend/src/lib/components/graph/noteManager.svelte.ts +++ b/frontend/src/lib/components/graph/noteManager.svelte.ts @@ -19,9 +19,17 @@ export type TextHeightCacheEntry = { */ export class NoteManager { #cache: Record = $state({}) + renderCount = $state(0) constructor() {} + /** + * Triggers a re-render of the graph by incrementing the render count + */ + render(): void { + this.renderCount++ + } + getCache(): Record { return this.#cache } @@ -169,22 +177,27 @@ export class NoteManager { onUpdate: (text: string) => { const newNotes = this.updateText(notes, note.id, text) onNotesChange(newNotes) + this.render() }, onDelete: () => { const newNotes = this.delete(notes, note.id) onNotesChange(newNotes) + this.render() }, onColorChange: (color: NoteColor) => { const newNotes = this.updateColor(notes, note.id, color) onNotesChange(newNotes) + this.render() }, onSizeChange: (size: { width: number; height: number }) => { const newNotes = this.updateSize(notes, note.id, size) onNotesChange(newNotes) + this.render() }, onLockToggle: (locked: boolean) => { const newNotes = this.updateLock(notes, note.id, locked) onNotesChange(newNotes) + this.render() }, onTextHeightChange: (textHeight: number) => { onTextHeightChange(note.id, textHeight) @@ -232,6 +245,7 @@ export class NoteManager { */ cacheTextHeight(noteId: string, content: string, height: number): void { this.#cache[noteId] = { content, height } + this.render() } /** @@ -277,6 +291,7 @@ export class NoteManager { */ clearTextHeightCache(): void { this.#cache = {} + this.render() } /** @@ -284,5 +299,6 @@ export class NoteManager { */ removeTextHeight(noteId: string): void { delete this.#cache[noteId] + this.render() } }