From 6b8a6219134267b54e89c6396ab85c1119b20564 Mon Sep 17 00:00:00 2001 From: PJ-Watson <59647390+PJ-Watson@users.noreply.github.com> Date: Sun, 26 Sep 2021 21:17:16 +0100 Subject: [PATCH] Fix bug in new install. --- .../timelineGallery/TimelineFilters.tsx | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ui/src/components/timelineGallery/TimelineFilters.tsx b/ui/src/components/timelineGallery/TimelineFilters.tsx index 53df5eac..0884a270 100644 --- a/ui/src/components/timelineGallery/TimelineFilters.tsx +++ b/ui/src/components/timelineGallery/TimelineFilters.tsx @@ -38,23 +38,25 @@ const DateSelector = ({ filterDate, setFilterDate }: DateSelectorProps) => { ] if (data) { - const dateStr = data.myMedia[0].date - const date = new Date(dateStr) - const now = new Date() + if (data.myMedia.length != 0) { + const dateStr = data.myMedia[0].date + const date = new Date(dateStr) + const now = new Date() - const currentYear = now.getFullYear() - const earliestYear = date.getFullYear() + const currentYear = now.getFullYear() + const earliestYear = date.getFullYear() - const years: number[] = [] - for (let i = currentYear - 1; i >= earliestYear; i--) { - years.push(i) + const years: number[] = [] + for (let i = currentYear - 1; i >= earliestYear; i--) { + years.push(i) + } + + const yearItems = years.map(x => ({ + value: `${x}`, + label: `${x} and earlier`, + })) + items = [...items, ...yearItems] } - - const yearItems = years.map(x => ({ - value: `${x}`, - label: `${x} and earlier`, - })) - items = [...items, ...yearItems] } return (