Support timezones (#11434)

* Handle offset timezones

* Fix previews loading

* Cleanup

* remove unused
This commit is contained in:
Nicolas Mowen
2024-05-19 17:08:32 -06:00
committed by GitHub
parent bca01cb43c
commit 4c87ef56c7
5 changed files with 46 additions and 17 deletions
@@ -12,6 +12,7 @@ import ActivityIndicator from "@/components/indicators/activity-indicator";
import { VideoResolutionType } from "@/types/live";
import axios from "axios";
import { cn } from "@/lib/utils";
import { getUTCOffset } from "@/utils/dateUtil";
/**
* Dynamically switches between video playback and scrubbing preview player.
@@ -148,9 +149,12 @@ export default function DynamicVideoPlayer({
// state of playback player
const recordingParams = useMemo(() => {
const timeRangeOffset =
(getUTCOffset(new Date(timeRange.before * 1000)) % 60) * 60;
return {
before: timeRange.before,
after: timeRange.after,
before: timeRange.before + timeRangeOffset,
after: timeRange.after + timeRangeOffset,
};
}, [timeRange]);
const { data: recordings } = useSWR<Recording[]>(
@@ -168,7 +172,7 @@ export default function DynamicVideoPlayer({
}
setSource(
`${apiHost}vod/${camera}/start/${timeRange.after}/end/${timeRange.before}/master.m3u8`,
`${apiHost}vod/${camera}/start/${recordingParams.after}/end/${recordingParams.before}/master.m3u8`,
);
setLoadingTimeout(setTimeout(() => setIsLoading(true), 1000));