From ce2a7ed43e6da44ba9f049b701697eabf1271906 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Mon, 30 Mar 2026 23:08:37 +0700 Subject: [PATCH] Refactor alias selection logic in AliasFilterSelect component - Simplified the internal state management for alias selection, ensuring the selected value is consistent with available aliases. - Updated the effect handling to directly modify the `value` prop based on alias availability, improving responsiveness. - Streamlined the binding in the Select component to enhance the alias selection process. --- .../lib/components/alias-filter-select.svelte | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/web/src/lib/components/alias-filter-select.svelte b/web/src/lib/components/alias-filter-select.svelte index a9f0567..aa69773 100644 --- a/web/src/lib/components/alias-filter-select.svelte +++ b/web/src/lib/components/alias-filter-select.svelte @@ -13,26 +13,21 @@ allLabel?: string; } = $props(); - let internalValue = $state(value ?? "all"); - $effect(() => { - const next = value ?? "all"; - if (internalValue !== next) internalValue = next; - }); - - $effect(() => { - if (internalValue !== "all" && !availableAliases.includes(internalValue)) { - internalValue = "all"; + if ((value ?? "all") !== "all" && !availableAliases.includes(value ?? "all")) { + value = "all"; + } + if (!value) { + value = "all"; } - if (value !== internalValue) value = internalValue; }); - let selectedLabel = $derived(internalValue === "all" ? allLabel : internalValue); + let selectedLabel = $derived((value ?? "all") === "all" ? allLabel : (value ?? "all"));