From 46020693cd376ca96f74ece8ab66ec6064f32929 Mon Sep 17 00:00:00 2001 From: JohnMark Sill Date: Fri, 14 Jan 2022 16:45:29 -0600 Subject: [PATCH] fix: replace time search with 24 hour --- web/src/components/HistoryViewer.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web/src/components/HistoryViewer.jsx b/web/src/components/HistoryViewer.jsx index cbfb94500..b8f27c0bd 100644 --- a/web/src/components/HistoryViewer.jsx +++ b/web/src/components/HistoryViewer.jsx @@ -1,5 +1,5 @@ import { Fragment, h } from 'preact'; -import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks'; import { useApiHost, useEvents } from '../api'; import { useSearchString } from '../hooks/useSearchString'; import { Next } from '../icons/Next'; @@ -9,13 +9,15 @@ import { HistoryHeader } from '../routes/HistoryHeader'; import { longToDate } from '../utils/dateUtil'; import Timeline from './Timeline'; +const getLast24Hours = () => { + return new Number(new Date(new Date().getTime() - 24 * 60 * 60 * 1000)) / 1000; +}; + export default function HistoryViewer({ camera }) { + console.log('history', { camera }); const apiHost = useApiHost(); const videoRef = useRef(); - - // const beginningOfDay = new Date().setHour(0, 0, 0) / 1000; - const beginningOfDay = new Date(new Date().getTime() - 24 * 60 * 60 * 1000); - const { searchString } = useSearchString(200, `camera=${camera}&after=${beginningOfDay}`); + const { searchString } = useSearchString(200, `camera=${camera}&after=${getLast24Hours()}`); const { data: events } = useEvents(searchString); const [timelineEvents, setTimelineEvents] = useState();