From b4a66b29e20a13ab457b32d8849d5ae85b595b74 Mon Sep 17 00:00:00 2001 From: Quick <31828688+Quick104@users.noreply.github.com> Date: Fri, 26 Jun 2026 12:46:40 -0400 Subject: [PATCH] fix(web): preserve untouched metadata levels when toggling a provider (#226) toggleLevelProvider merged the toggled level into the levelChains state object, which starts empty. After the first toggle the state collapsed to a single level, so once chainDirty flipped true activeLevelChains dropped every untouched level and the dialog rendered them empty. Seed from the full resolved activeLevelChains map and write it back the same way reorderLevel already does, so disabling a source on one TV level no longer blanks the others on the first toggle. The earlier redesign (b9a9613) only patched the per-level source fallback, which kept the toggled level's items but did not preserve the rest of the map; builds containing it still reproduced the issue. Part of #213 Co-authored-by: Claude Opus 4.8 --- web/src/components/admin/libraries/useLibraryForm.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web/src/components/admin/libraries/useLibraryForm.ts b/web/src/components/admin/libraries/useLibraryForm.ts index e7cab4f5..c30ee7fe 100644 --- a/web/src/components/admin/libraries/useLibraryForm.ts +++ b/web/src/components/admin/libraries/useLibraryForm.ts @@ -257,12 +257,10 @@ export function useLibraryForm({ } function toggleLevelProvider(level: string, index: number) { - setLevelChains((prev) => { - const source = prev[level] ?? activeLevelChains[level] ?? []; - const updated = [...source]; - updated[index] = { ...updated[index]!, enabled: !updated[index]!.enabled }; - return { ...prev, [level]: updated }; - }); + const source = activeLevelChains[level] ?? []; + const updated = [...source]; + updated[index] = { ...updated[index]!, enabled: !updated[index]!.enabled }; + setLevelChains({ ...activeLevelChains, [level]: updated }); setChainDirty(true); }