NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Ensure that persisted state is kept in sync (#12596)
Nicolas Mowen5c15659a34c8
diff --git a/web/src/hooks/use-overlay-state.tsx b/web/src/hooks/use-overlay-state.tsxindex 573598b0c2..0db339c9b8 100644--- a/web/src/hooks/use-overlay-state.tsx+++ b/web/src/hooks/use-overlay-state.tsx@@ -38,12 +38,22 @@ export function usePersistedOverlayState<S extends string>((value: S | undefined, replace?: boolean) => void,() => void,] {- const [persistedValue, setPersistedValue, , deletePersistedValue] =- usePersistence<S>(key, defaultValue);const location = useLocation();const navigate = useNavigate();const currentLocationState = useMemo(() => location.state, [location]);+ // currently selected value++ const overlayStateValue = useMemo<S | undefined>(+ () => location.state && location.state[key],+ [location, key],+ );++ // saved value from previous session++ const [persistedValue, setPersistedValue, , deletePersistedValue] =+ usePersistence<S>(key, overlayStateValue);+const setOverlayStateValue = useCallback((value: S | undefined, replace: boolean = false) => {setPersistedValue(value);@@ -56,11 +66,6 @@ export function usePersistedOverlayState<S extends string>([key, currentLocationState, navigate],);- const overlayStateValue = useMemo<S | undefined>(- () => location.state && location.state[key],- [location, key],- );-return [overlayStateValue ?? persistedValue ?? defaultValue,setOverlayStateValue,diff --git a/web/src/hooks/use-persistence.ts b/web/src/hooks/use-persistence.tsindex 8762c19701..6478769a98 100644--- a/web/src/hooks/use-persistence.ts+++ b/web/src/hooks/use-persistence.ts@@ -34,7 +34,6 @@ export function usePersistence<S>(useEffect(() => {setLoaded(false);- setInternalValue(defaultValue);async function load() {const value = await getData(key);