Skip to content

NVR with realtime local object detection for IP cameras

Ensure time range filter retains selected values (#17147)

Josh Hawkinsfe078666c62a
diff --git a/web/src/components/overlay/dialog/SearchFilterDialog.tsx b/web/src/components/overlay/dialog/SearchFilterDialog.tsx
index 2768f88591..7fadc1dac2 100644
--- a/web/src/components/overlay/dialog/SearchFilterDialog.tsx
+++ b/web/src/components/overlay/dialog/SearchFilterDialog.tsx
@@ -254,11 +254,13 @@ function TimeRangeFilterContent({
const [endOpen, setEndOpen] = useState(false);
const [afterHour, beforeHour] = useMemo(() => {
- if (!timeRange || !timeRange.includes(",")) {
- return [DEFAULT_TIME_RANGE_AFTER, DEFAULT_TIME_RANGE_BEFORE];
+ if (Array.isArray(timeRange) && timeRange.length === 2) {
+ return timeRange;
}
-
- return timeRange.split(",");
+ if (typeof timeRange === "string" && timeRange.includes(",")) {
+ return timeRange.split(",");
+ }
+ return [DEFAULT_TIME_RANGE_AFTER, DEFAULT_TIME_RANGE_BEFORE];
}, [timeRange]);
const [selectedAfterHour, setSelectedAfterHour] = useState(afterHour);