mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Use memo for recordings timezone (#5086)
This commit is contained in:
parent
24410849b7
commit
19d17c8c81
@ -296,6 +296,7 @@ export default function Events({ path, ...props }) {
|
||||
}
|
||||
|
||||
const timezone = config.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const locale = window.navigator?.language || 'en-US';
|
||||
|
||||
return (
|
||||
<div className="space-y-4 p-2 px-4 w-full">
|
||||
@ -514,8 +515,8 @@ export default function Events({ path, ...props }) {
|
||||
({(event.top_score * 100).toFixed(0)}%)
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
{new Date(event.start_time * 1000).toLocaleDateString({ timeZone: timezone })}{' '}
|
||||
{new Date(event.start_time * 1000).toLocaleTimeString({ timeZone: timezone })} (
|
||||
{new Date(event.start_time * 1000).toLocaleDateString(locale, { timeZone: timezone })}{' '}
|
||||
{new Date(event.start_time * 1000).toLocaleTimeString(locale, { timeZone: timezone })} (
|
||||
{clipDuration(event.start_time, event.end_time)})
|
||||
</div>
|
||||
<div className="capitalize text-sm flex align-center mt-1">
|
||||
|
@ -10,11 +10,11 @@ import useSWR from 'swr';
|
||||
|
||||
export default function Recording({ camera, date, hour = '00', minute = '00', second = '00' }) {
|
||||
const { data: config } = useSWR('config');
|
||||
let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
const currentDate = useMemo(
|
||||
() => (date ? parseISO(`${date}T${hour || '00'}:${minute || '00'}:${second || '00'}`) : new Date()),
|
||||
[date, hour, minute, second]
|
||||
);
|
||||
const timezone = useMemo(() => config.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone, [config]);
|
||||
|
||||
const apiHost = useApiHost();
|
||||
const { data: recordingsSummary } = useSWR([`${camera}/recordings/summary`, { timezone }], {
|
||||
@ -118,10 +118,6 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se
|
||||
return <ActivityIndicator />;
|
||||
}
|
||||
|
||||
if (config.ui.timezone) {
|
||||
timezone = config.ui.timezone;
|
||||
}
|
||||
|
||||
if (recordingsSummary.length === 0) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
|
Loading…
Reference in New Issue
Block a user