Dont reset inprogress settings when backend loads

useDerived resets its local edit whenever initial changes. When the async loadSettings() completes it updates the store, so initial changes and the effect clears the user's toggle before they click Save. Fixing by: 1) removing the effect in useDerived that clears overwrite when initial changes; 2) calling state.reset() in Settings after applying loaded settings so the form reflects backend values without wiping in-progress edits.
This commit is contained in:
Pas 2026-02-20 23:13:48 -07:00
parent 8cb8d158f6
commit 126d9c0b49
2 changed files with 1 additions and 4 deletions

View file

@ -2,7 +2,6 @@ import {
Dispatch,
SetStateAction,
useCallback,
useEffect,
useMemo,
useState,
} from "react";
@ -14,9 +13,6 @@ export function useDerived<T>(
initial: T,
): [T, Dispatch<SetStateAction<T>>, () => void, boolean] {
const [overwrite, setOverwrite] = useState<T | undefined>(undefined);
useEffect(() => {
setOverwrite(undefined);
}, [initial]);
const changed = useMemo(
() =>
JSON.stringify(overwrite) !== JSON.stringify(initial) &&

View file

@ -667,6 +667,7 @@ export function SettingsPage() {
} else {
setCustomThemeBaseline(useThemeStore.getState().customTheme);
}
state.reset();
}
};
loadSettings();