From 18d413fbee0c87d7472026ec1a2a99bf398b434c Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:35:12 -0500 Subject: [PATCH] tweaks --- web/src/pages/Settings.tsx | 31 +++++++++++++++ web/src/types/profile.ts | 1 + web/src/views/settings/ProfilesView.tsx | 53 +++++++++++++++++-------- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/web/src/pages/Settings.tsx b/web/src/pages/Settings.tsx index d1cf9a21c..54a9de362 100644 --- a/web/src/pages/Settings.tsx +++ b/web/src/pages/Settings.tsx @@ -1067,6 +1067,33 @@ export default function Settings() { setNewProfiles((prev) => (prev.includes(name) ? prev : [...prev, name])); }, []); + const handleRemoveNewProfile = useCallback((name: string) => { + setNewProfiles((prev) => prev.filter((p) => p !== name)); + // Clear any editing state for this profile + setEditingProfile((prev) => { + const updated = { ...prev }; + for (const key of Object.keys(updated)) { + if (updated[key] === name) { + delete updated[key]; + } + } + return updated; + }); + // Clear any pending data for this profile + setPendingDataBySection((prev) => { + const profileSegment = `profiles.${name}.`; + const updated = { ...prev }; + let changed = false; + for (const key of Object.keys(updated)) { + if (key.includes(profileSegment)) { + delete updated[key]; + changed = true; + } + } + return changed ? updated : prev; + }); + }, []); + const handleDeleteProfileSection = useCallback( async (camera: string, section: string, profile: string) => { try { @@ -1105,6 +1132,7 @@ export default function Settings() { allProfileNames, onSelectProfile: handleSelectProfile, onAddProfile: handleAddProfile, + onRemoveNewProfile: handleRemoveNewProfile, onDeleteProfileSection: handleDeleteProfileSection, }), [ @@ -1113,6 +1141,7 @@ export default function Settings() { allProfileNames, handleSelectProfile, handleAddProfile, + handleRemoveNewProfile, handleDeleteProfileSection, ], ); @@ -1780,6 +1809,8 @@ export default function Settings() { pendingDataBySection={pendingDataBySection} onPendingDataChange={handlePendingDataChange} profileState={profileState} + profilesUIEnabled={profilesUIEnabled} + setProfilesUIEnabled={setProfilesUIEnabled} /> ); })()} diff --git a/web/src/types/profile.ts b/web/src/types/profile.ts index 2c96e51da..3a6441a26 100644 --- a/web/src/types/profile.ts +++ b/web/src/types/profile.ts @@ -15,6 +15,7 @@ export type ProfileState = { profile: string | null, ) => void; onAddProfile: (name: string) => void; + onRemoveNewProfile: (name: string) => void; onDeleteProfileSection: ( camera: string, section: string, diff --git a/web/src/views/settings/ProfilesView.tsx b/web/src/views/settings/ProfilesView.tsx index 07883ab38..cc63619d2 100644 --- a/web/src/views/settings/ProfilesView.tsx +++ b/web/src/views/settings/ProfilesView.tsx @@ -142,6 +142,15 @@ export default function ProfilesView({ const handleDeleteProfile = useCallback(async () => { if (!deleteProfile || !config) return; + + // If this is an unsaved (new) profile, just remove it from local state + const isNewProfile = profileState?.newProfiles.includes(deleteProfile); + if (isNewProfile) { + profileState?.onRemoveNewProfile(deleteProfile); + setDeleteProfile(null); + return; + } + setDeleting(true); try { @@ -184,7 +193,15 @@ export default function ProfilesView({ setDeleting(false); setDeleteProfile(null); } - }, [deleteProfile, activeProfile, config, updateConfig, updateProfiles, t]); + }, [ + deleteProfile, + activeProfile, + config, + profileState, + updateConfig, + updateProfiles, + t, + ]); if (!config || !profilesData) { return null; @@ -193,14 +210,15 @@ export default function ProfilesView({ const hasProfiles = allProfileNames.length > 0; return ( -
- - {t("profiles.title", { ns: "views/settings" })} - +
+ {t("profiles.title", { ns: "views/settings" })} +
+ {t("profiles.disabledDescription", { ns: "views/settings" })} +
{/* Enable Profiles Toggle — shown only when no profiles exist */} {!hasProfiles && setProfilesUIEnabled && ( -
+
-

- {profilesUIEnabled - ? t("profiles.enabledDescription", { ns: "views/settings" }) - : t("profiles.disabledDescription", { ns: "views/settings" })} -

)} + {profilesUIEnabled && ( +

+ {t("profiles.enabledDescription", { ns: "views/settings" })} +

+ )} + {/* Active Profile Section — only when profiles exist */} {hasProfiles && (
@@ -275,11 +294,13 @@ export default function ProfilesView({ {/* Profile Cards */} {!hasProfiles ? ( -
- {!profilesUIEnabled && ( -

{t("profiles.noProfiles", { ns: "views/settings" })}

- )} -
+ profilesUIEnabled ? ( +

+ {t("profiles.noProfiles", { ns: "views/settings" })} +

+ ) : ( +
+ ) ) : (
{allProfileNames.map((profile) => {