mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-17 16:44:29 +03:00
Allow customizing if search is preserved for overlay state
This commit is contained in:
parent
9f0d29feab
commit
1a23fdeff2
@ -5,6 +5,7 @@ import { usePersistence } from "./use-persistence";
|
|||||||
export function useOverlayState<S>(
|
export function useOverlayState<S>(
|
||||||
key: string,
|
key: string,
|
||||||
defaultValue: S | undefined = undefined,
|
defaultValue: S | undefined = undefined,
|
||||||
|
preserveSearch: boolean = true,
|
||||||
): [S | undefined, (value: S, replace?: boolean) => void] {
|
): [S | undefined, (value: S, replace?: boolean) => void] {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -15,7 +16,7 @@ export function useOverlayState<S>(
|
|||||||
(value: S, replace: boolean = false) => {
|
(value: S, replace: boolean = false) => {
|
||||||
const newLocationState = { ...currentLocationState };
|
const newLocationState = { ...currentLocationState };
|
||||||
newLocationState[key] = value;
|
newLocationState[key] = value;
|
||||||
navigate(location.pathname + location.search, {
|
navigate(location.pathname + (preserveSearch ? location.search : ""), {
|
||||||
state: newLocationState,
|
state: newLocationState,
|
||||||
replace,
|
replace,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -39,8 +39,11 @@ export default function Events() {
|
|||||||
|
|
||||||
const [showReviewed, setShowReviewed] = usePersistence("showReviewed", false);
|
const [showReviewed, setShowReviewed] = usePersistence("showReviewed", false);
|
||||||
|
|
||||||
const [recording, setRecording] =
|
const [recording, setRecording] = useOverlayState<RecordingStartingPoint>(
|
||||||
useOverlayState<RecordingStartingPoint>("recording");
|
"recording",
|
||||||
|
undefined,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
useSearchEffect("id", (reviewId: string) => {
|
useSearchEffect("id", (reviewId: string) => {
|
||||||
axios
|
axios
|
||||||
@ -50,6 +53,7 @@ export default function Events() {
|
|||||||
const startTime = resp.data.start_time - REVIEW_PADDING;
|
const startTime = resp.data.start_time - REVIEW_PADDING;
|
||||||
const date = new Date(startTime * 1000);
|
const date = new Date(startTime * 1000);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
setReviewFilter({
|
setReviewFilter({
|
||||||
after: getBeginningOfDayTimestamp(date),
|
after: getBeginningOfDayTimestamp(date),
|
||||||
before: getEndOfDayTimestamp(date),
|
before: getEndOfDayTimestamp(date),
|
||||||
@ -62,6 +66,7 @@ export default function Events() {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user