From db4878122114f0c1221193c4ef13936edd2129ce Mon Sep 17 00:00:00 2001 From: joren Date: Thu, 2 Apr 2026 19:16:55 +0200 Subject: [PATCH] fix: optimistically update nodes store when loading profile volumes setNodeVolume/setNodeMute only send API requests; the nodes store wasn't updated until the backend broadcast a graph change, so sliders showed stale values. Now the store is updated immediately before firing the API calls. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/lib/stores.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/src/lib/stores.ts b/frontend/src/lib/stores.ts index f6d86cf..4cc5f0b 100644 --- a/frontend/src/lib/stores.ts +++ b/frontend/src/lib/stores.ts @@ -349,6 +349,17 @@ export async function saveProfile(name: string) { async function applyProfileVolumes(profile: PatchbayProfile) { if (!profile.volumes && !profile.mutes) return; const currentNodes = get_store_value(nodes); + + // Optimistically update store so sliders reflect new values immediately + nodes.update(ns => ns.map(n => { + const vol = profile.volumes?.[n.name]; + const mute = profile.mutes?.[n.name]; + if (vol !== undefined || mute !== undefined) { + return { ...n, ...(vol !== undefined ? { volume: vol } : {}), ...(mute !== undefined ? { mute } : {}) }; + } + return n; + })); + for (const n of currentNodes) { if (profile.volumes?.[n.name] !== undefined) { await setNodeVolume(n.id, profile.volumes[n.name]);