remember last selected history sidebar tab (#24488)

The History view always opened on Timeline unless the link carried a tab. The selected tab is now saved with useUserPersistence and used as the default when no tab is passed. Notification and shared review links no longer default to "timeline", so they pick up the saved tab too, and `?tab=` still overrides it.
This commit is contained in:
Josh Hawkins 2026-09-27 18:21:46 -05:00 committed by GitHub
parent 0977fa5e15
commit f9a37d4f4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 4 deletions

View File

@ -132,8 +132,7 @@ export default function Events() {
setMotionSearchDay(normalizedDay);
}, []);
const [notificationTab, setNotificationTab] =
useState<TimelineType>("timeline");
const [notificationTab, setNotificationTab] = useState<TimelineType>();
const getReviewDayBounds = useCallback((date: Date) => {
const now = Date.now() / 1000;

View File

@ -14,6 +14,7 @@ import { Button } from "@/components/ui/button";
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
import { useOverlayState } from "@/hooks/use-overlay-state";
import { usePersistence } from "@/hooks/use-persistence";
import { useUserPersistence } from "@/hooks/use-user-persistence";
import { useResizeObserver } from "@/hooks/resize-observer";
import { DEFAULT_DRAWER_FEATURES, ExportMode } from "@/types/filter";
import { FrigateConfig } from "@/types/frigateConfig";
@ -182,9 +183,19 @@ export function RecordingView({
false,
);
const [timelineType, setTimelineType] = useOverlayState<TimelineType>(
const [savedTimelineType, setSavedTimelineType] =
useUserPersistence<TimelineType>("recordingTimelineType");
const [timelineType, setOverlayTimelineType] = useOverlayState<TimelineType>(
"timelineType",
recording?.timelineType ?? "timeline",
recording?.timelineType ?? savedTimelineType ?? "timeline",
);
const setTimelineType = useCallback(
(value: TimelineType, replace?: boolean) => {
setOverlayTimelineType(value, replace);
setSavedTimelineType(value);
},
[setOverlayTimelineType, setSavedTimelineType],
);
const chunkedTimeRange = useMemo(