mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Fix persistence typing
This commit is contained in:
parent
9c519b9dad
commit
a251f1fee6
@ -22,7 +22,7 @@ export default function DebugCameraImage({
|
||||
cameraConfig,
|
||||
}: DebugCameraImageProps) {
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const [options, setOptions] = usePersistence(
|
||||
const [options, setOptions] = usePersistence<Options>(
|
||||
`${cameraConfig?.name}-feed`,
|
||||
emptyObject
|
||||
);
|
||||
@ -36,7 +36,7 @@ export default function DebugCameraImage({
|
||||
const searchParams = useMemo(
|
||||
() =>
|
||||
new URLSearchParams(
|
||||
Object.keys(options).reduce((memo, key) => {
|
||||
Object.keys(options || {}).reduce((memo, key) => {
|
||||
//@ts-ignore we know this is correct
|
||||
memo.push([key, options[key] === true ? "1" : "0"]);
|
||||
return memo;
|
||||
@ -68,7 +68,7 @@ export default function DebugCameraImage({
|
||||
<CardContent>
|
||||
<DebugSettings
|
||||
handleSetOption={handleSetOption}
|
||||
options={options}
|
||||
options={options || {}}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -3,7 +3,7 @@ import { get as getData, set as setData } from "idb-keyval";
|
||||
|
||||
type usePersistenceReturn<S extends any> = [
|
||||
value: S | undefined,
|
||||
setValue: (value: string | boolean) => void,
|
||||
setValue: (value: S) => void,
|
||||
loaded: boolean,
|
||||
];
|
||||
|
||||
@ -15,7 +15,7 @@ export function usePersistence<S>(
|
||||
const [loaded, setLoaded] = useState<boolean>(false);
|
||||
|
||||
const setValue = useCallback(
|
||||
(value: string | boolean) => {
|
||||
(value: S) => {
|
||||
setInternalValue(value);
|
||||
async function update() {
|
||||
await setData(key, value);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user