mirror of
https://github.com/p-stream/p-stream.git
synced 2026-03-11 09:45:33 +00:00
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:
parent
8cb8d158f6
commit
126d9c0b49
2 changed files with 1 additions and 4 deletions
|
|
@ -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) &&
|
||||
|
|
|
|||
|
|
@ -667,6 +667,7 @@ export function SettingsPage() {
|
|||
} else {
|
||||
setCustomThemeBaseline(useThemeStore.getState().customTheme);
|
||||
}
|
||||
state.reset();
|
||||
}
|
||||
};
|
||||
loadSettings();
|
||||
|
|
|
|||
Loading…
Reference in a new issue