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 timezone = config.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
|
const locale = window.navigator?.language || 'en-US';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4 p-2 px-4 w-full">
|
<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)}%)
|
({(event.top_score * 100).toFixed(0)}%)
|
||||||
</div>
|
</div>
|
||||||
<div className="text-sm">
|
<div className="text-sm">
|
||||||
{new Date(event.start_time * 1000).toLocaleDateString({ timeZone: timezone })}{' '}
|
{new Date(event.start_time * 1000).toLocaleDateString(locale, { timeZone: timezone })}{' '}
|
||||||
{new Date(event.start_time * 1000).toLocaleTimeString({ timeZone: timezone })} (
|
{new Date(event.start_time * 1000).toLocaleTimeString(locale, { timeZone: timezone })} (
|
||||||
{clipDuration(event.start_time, event.end_time)})
|
{clipDuration(event.start_time, event.end_time)})
|
||||||
</div>
|
</div>
|
||||||
<div className="capitalize text-sm flex align-center mt-1">
|
<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' }) {
|
export default function Recording({ camera, date, hour = '00', minute = '00', second = '00' }) {
|
||||||
const { data: config } = useSWR('config');
|
const { data: config } = useSWR('config');
|
||||||
let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
||||||
const currentDate = useMemo(
|
const currentDate = useMemo(
|
||||||
() => (date ? parseISO(`${date}T${hour || '00'}:${minute || '00'}:${second || '00'}`) : new Date()),
|
() => (date ? parseISO(`${date}T${hour || '00'}:${minute || '00'}:${second || '00'}`) : new Date()),
|
||||||
[date, hour, minute, second]
|
[date, hour, minute, second]
|
||||||
);
|
);
|
||||||
|
const timezone = useMemo(() => config.ui?.timezone || Intl.DateTimeFormat().resolvedOptions().timeZone, [config]);
|
||||||
|
|
||||||
const apiHost = useApiHost();
|
const apiHost = useApiHost();
|
||||||
const { data: recordingsSummary } = useSWR([`${camera}/recordings/summary`, { timezone }], {
|
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 />;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.ui.timezone) {
|
|
||||||
timezone = config.ui.timezone;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (recordingsSummary.length === 0) {
|
if (recordingsSummary.length === 0) {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
|
Loading…
Reference in New Issue
Block a user