diff --git a/web/src/utils/historyUtil.ts b/web/src/utils/historyUtil.ts index b372dc1c2..ec2145789 100644 --- a/web/src/utils/historyUtil.ts +++ b/web/src/utils/historyUtil.ts @@ -101,3 +101,26 @@ export function getHourlyTimelineData( return cards; } + +export function getTimelineHoursForDay(timestamp: number) { + const now = new Date(); + const data = []; + const startDay = new Date(timestamp * 1000); + startDay.setHours(0, 0, 0, 0); + let start = startDay.getTime() / 1000; + let end = 0; + + for (let i = 0; i < 24; i++) { + startDay.setHours(startDay.getHours() + 1); + + if (startDay > now) { + break; + } + + end = startDay.getTime() / 1000; + data.push({ start, end }); + start = startDay.getTime() / 1000; + } + + return data.reverse(); +} diff --git a/web/src/views/history/HistoryTimelineView.tsx b/web/src/views/history/HistoryTimelineView.tsx index 36d2ac743..cd821430c 100644 --- a/web/src/views/history/HistoryTimelineView.tsx +++ b/web/src/views/history/HistoryTimelineView.tsx @@ -21,6 +21,7 @@ import React, { import useSWR from "swr"; import Player from "video.js/dist/types/player"; import TimelineItemCard from "@/components/card/TimelineItemCard"; +import { getTimelineHoursForDay } from "@/utils/historyUtil"; type HistoryTimelineViewProps = { playback: TimelinePlayback; @@ -255,6 +256,9 @@ function DesktopView({ onScrubTime, onStopScrubbing, }: DesktopViewProps) { + const timelineStack = + playback == undefined ? [] : getTimelineHoursForDay(timelineTime); + return (