forked from Github/frigate
Refactor history viewer to show player / timeline for full hour and use preview while scrubbing timeline (#9051)
* Move history card view to separate view and create timeline view * Get custom time scrubber working * Add back nav * Show timeline bounding boxes * Implement seeking limiter * Use browser history to allow back button to close timeline viewer * Fix mobile timeline and add more icons for detections * Play when item is initially visible
This commit is contained in:
committed by
Blake Blackshear
parent
9a0dfa723a
commit
a946a8f099
20
web/src/hooks/use-overlay-state.tsx
Normal file
20
web/src/hooks/use-overlay-state.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useCallback } from "react";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
|
||||
export default function useOverlayState(key: string) {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const currentLocationState = location.state;
|
||||
|
||||
const setOverlayStateValue = useCallback(
|
||||
(value: string) => {
|
||||
const newLocationState = { ...currentLocationState };
|
||||
newLocationState[key] = value;
|
||||
navigate(location.pathname, { state: newLocationState });
|
||||
},
|
||||
[navigate]
|
||||
);
|
||||
|
||||
const overlayStateValue = location.state && location.state[key];
|
||||
return [overlayStateValue, setOverlayStateValue];
|
||||
}
|
||||
Reference in New Issue
Block a user