From 94859c3543cb06315768c24b9a669fd2a633ec5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 1 Jun 2020 22:19:35 +0200 Subject: [PATCH] Check that each location's latest photo exists --- src/routes/_layout.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/_layout.svelte b/src/routes/_layout.svelte index 2623629..4e66a19 100644 --- a/src/routes/_layout.svelte +++ b/src/routes/_layout.svelte @@ -99,7 +99,9 @@ // Add last updated date to each location data.locations.data.forEach(location => { const latestPhoto = latestPhotos.find(photo => photo.location.id === location.id) - location.last_updated = latestPhoto.created_on + if (latestPhoto) { + location.last_updated = latestPhoto.created_on + } }) // Set data into store @@ -171,7 +173,7 @@ {/each} - +