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 <noreply@anthropic.com>
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user