From 1765ab89e741a8904ab6a5880db0dba08a5bc27d Mon Sep 17 00:00:00 2001 From: Denozordec Date: Wed, 8 Apr 2026 20:57:29 +0700 Subject: [PATCH] refactor: streamline edit form handling for community and DoH profile selections Removed unnecessary state variables for community and DoH profile selections in the edit form. Updated the handling of these selections to directly utilize values from the edit form, improving code clarity and reducing redundancy. This change enhances the overall user experience by simplifying the state management in the module edit process. --- web/src/routes/modules/[moduleId]/+page.svelte | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/web/src/routes/modules/[moduleId]/+page.svelte b/web/src/routes/modules/[moduleId]/+page.svelte index c866b7e..e71dc6d 100644 --- a/web/src/routes/modules/[moduleId]/+page.svelte +++ b/web/src/routes/modules/[moduleId]/+page.svelte @@ -146,8 +146,6 @@ // Module edit let editDialog = $state(false); let editForm = $state({}); - let editDefaultCommunitySelect = $state('__none__'); - let editDohProfileSelect = $state('__none__'); let editSaving = $state(false); let deleteModDialog = $state(false); let deletingMod = $state(false); @@ -267,8 +265,6 @@ default_community_id: mod.default_community_id, doh_profile_id: mod.doh_profile_id }; - editDefaultCommunitySelect = nullableSelectValue(mod.default_community_id); - editDohProfileSelect = nullableSelectValue(mod.doh_profile_id); editDialog = true; } @@ -285,8 +281,8 @@ ...editForm, cron_expr: cron ? cron : null, refresh_interval_sec: Number.isFinite(interval) ? interval : null, - default_community_id: fromNullableSelect(editDefaultCommunitySelect), - doh_profile_id: fromNullableSelect(editDohProfileSelect) + default_community_id: fromNullableSelect(nullableSelectValue(editForm.default_community_id)), + doh_profile_id: fromNullableSelect(nullableSelectValue(editForm.doh_profile_id)) }; await apiMutate(`/v1/modules/${moduleId}`, 'PATCH', payload); await loadMod(); @@ -1314,9 +1310,8 @@ { - editDohProfileSelect = nullableSelectValue(v); editForm.doh_profile_id = fromNullableSelect(v); }} > @@ -1369,7 +1362,6 @@ size="sm" class="h-7 px-2" onclick={() => { - editDohProfileSelect = NONE_OPTION; editForm.doh_profile_id = null; }} >