diff --git a/src/camera/CameraOverview.tsx b/src/camera/CameraOverview.tsx index 8128747d..0c058030 100644 --- a/src/camera/CameraOverview.tsx +++ b/src/camera/CameraOverview.tsx @@ -16,7 +16,7 @@ export default function CameraOverview({ camera: Camera, photos: Photo[], count: number, - dateRange: PhotoDateRange, + dateRange?: PhotoDateRange, showMorePath?: string, animateOnFirstLoadOnly?: boolean, }) { diff --git a/src/camera/CameraShareModal.tsx b/src/camera/CameraShareModal.tsx index 1dd33484..0bdb0884 100644 --- a/src/camera/CameraShareModal.tsx +++ b/src/camera/CameraShareModal.tsx @@ -13,7 +13,7 @@ export default function CameraShareModal({ camera: Camera photos: Photo[] count: number - dateRange: PhotoDateRange, + dateRange?: PhotoDateRange, }) { return ( sql` SELECT MIN(taken_at_naive) as start, MAX(taken_at_naive) as end FROM photos WHERE hidden IS NOT TRUE -`.then(({ rows }) => rows[0] as PhotoDateRange); +`.then(({ rows }) => rows[0]?.start && rows[0]?.end + ? rows[0] as PhotoDateRange + : undefined); const sqlGetPhotosTagDateRange = async (tag: string) => sql` SELECT MIN(taken_at_naive) as start, MAX(taken_at_naive) as end FROM photos WHERE ${tag}=ANY(tags) AND hidden IS NOT TRUE -`.then(({ rows }) => rows[0] as PhotoDateRange); +`.then(({ rows }) => rows[0]?.start && rows[0]?.end + ? rows[0] as PhotoDateRange + : undefined); const sqlGetPhotosCameraDateRange = async (camera: Camera) => sql` SELECT MIN(taken_at_naive) as start, MAX(taken_at_naive) as end @@ -206,7 +210,9 @@ const sqlGetPhotosCameraDateRange = async (camera: Camera) => sql` LOWER(make)=${parameterize(camera.make, true)} AND LOWER(REPLACE(model, ' ', '-'))=${parameterize(camera.model, true)} AND hidden IS NOT TRUE -`.then(({ rows }) => rows[0] as PhotoDateRange); +`.then(({ rows }) => rows[0]?.start && rows[0]?.end + ? rows[0] as PhotoDateRange + : undefined); const sqlGetPhotosFilmSimulationDateRange = async ( simulation: FilmSimulation, @@ -215,7 +221,9 @@ const sqlGetPhotosFilmSimulationDateRange = async ( FROM photos WHERE film_simulation=${simulation} AND hidden IS NOT TRUE -`.then(({ rows }) => rows[0] as PhotoDateRange); +`.then(({ rows }) => rows[0]?.start && rows[0]?.end + ? rows[0] as PhotoDateRange + : undefined); const sqlGetUniqueTags = async () => sql` SELECT DISTINCT unnest(tags) as tag, COUNT(*) diff --git a/src/simulation/FilmSimulationOverview.tsx b/src/simulation/FilmSimulationOverview.tsx index acb32584..bd1cbb9f 100644 --- a/src/simulation/FilmSimulationOverview.tsx +++ b/src/simulation/FilmSimulationOverview.tsx @@ -16,7 +16,7 @@ export default function FilmSimulationOverview({ simulation: FilmSimulation, photos: Photo[], count: number, - dateRange: PhotoDateRange, + dateRange?: PhotoDateRange, showMorePath?: string, animateOnFirstLoadOnly?: boolean, }) { diff --git a/src/tag/TagOverview.tsx b/src/tag/TagOverview.tsx index e81111cb..505ef098 100644 --- a/src/tag/TagOverview.tsx +++ b/src/tag/TagOverview.tsx @@ -15,7 +15,7 @@ export default function TagOverview({ tag: string, photos: Photo[], count: number, - dateRange: PhotoDateRange, + dateRange?: PhotoDateRange, showMorePath?: string, animateOnFirstLoadOnly?: boolean, }) {