diff --git a/web-new/src/pages/History.tsx b/web-new/src/pages/History.tsx
index cdba3dd69..f97072836 100644
--- a/web-new/src/pages/History.tsx
+++ b/web-new/src/pages/History.tsx
@@ -161,7 +161,7 @@ function History() {
[size, setSize, isValidating, isDone]
);
- if (!config || !timelineCards) {
+ if (!config || !timelineCards ||timelineCards.length == 0) {
return ;
}
@@ -186,12 +186,14 @@ function History() {
{Object.entries(timelineDay).map(
([hour, timelineHour], hourIdx) => {
if (Object.values(timelineHour).length == 0) {
- return <>>;
+ return
;
}
const lastRow =
dayIdx == Object.values(timelineCards).length - 1 &&
hourIdx == Object.values(timelineDay).length - 1;
+ const previewMap: { [key: string]: Preview | undefined } =
+ {};
return (
@@ -206,19 +208,23 @@ function History() {
([key, timeline]) => {
const startTs = Object.values(timeline.entries)[0]
.timestamp;
+ let relevantPreview = previewMap[timeline.camera];
+
+ if (relevantPreview == undefined) {
+ relevantPreview = previewMap[timeline.camera] =
+ Object.values(allPreviews || []).find(
+ (preview) =>
+ preview.camera == timeline.camera &&
+ preview.start < startTs &&
+ preview.end > startTs
+ );
+ }
return (
- preview.camera == timeline.camera &&
- preview.start < startTs &&
- preview.end > startTs
- )}
+ relevantPreview={relevantPreview}
/>
);
}
diff --git a/web-new/src/utils/dateUtil.ts b/web-new/src/utils/dateUtil.ts
index 8400aa549..053401b0b 100644
--- a/web-new/src/utils/dateUtil.ts
+++ b/web-new/src/utils/dateUtil.ts
@@ -105,7 +105,7 @@ const getResolvedTimeZone = () => {
*/
export const formatUnixTimestampToDateTime = (unixTimestamp: number, config: UiConfig): string => {
const { timezone, time_format, date_style, time_style, strftime_fmt } = config;
- const locale = window.navigator?.language || 'en-us';
+ const locale = window.navigator?.language || 'en-US';
if (isNaN(unixTimestamp)) {
return 'Invalid time';
}
@@ -117,7 +117,7 @@ export const formatUnixTimestampToDateTime = (unixTimestamp: number, config: UiC
// use strftime_fmt if defined in config
if (strftime_fmt) {
const offset = getUTCOffset(date, timezone || resolvedTimeZone);
- const strftime_locale = strftime.timezone(offset).localizeByIdentifier(locale);
+ const strftime_locale = strftime.timezone(offset);
return strftime_locale(strftime_fmt, date);
}