Check for when there are no photos

This commit is contained in:
2021-10-12 15:09:20 +02:00
parent ee851f2cfa
commit a92d5465e6

View File

@@ -23,6 +23,7 @@
let currentPage: number = 1 let currentPage: number = 1
let ended: boolean let ended: boolean
let currentPhotosAmount: number let currentPhotosAmount: number
$: latestPhoto = photos[0]
$: currentPhotosAmount = photos.length $: currentPhotosAmount = photos.length
$: ended = currentPhotosAmount === totalPhotos $: ended = currentPhotosAmount === totalPhotos
@@ -120,12 +121,14 @@
{/if} {/if}
{/each} {/each}
</p> </p>
&middot; {#if latestPhoto}
<p class="text-label" title={dayjs(photos[0].date_created).format('DD/MM/YYYY, hh:mm')}> &middot;
Updated <time datetime={dayjs(photos[0].date_created).format('YYYY-MM-DD')}> <p class="text-label" title={dayjs(latestPhoto.date_created).format('DD/MM/YYYY, hh:mm')}>
{dayjs().to(dayjs(photos[0].date_created))} Updated <time datetime={dayjs(latestPhoto.date_created).format('YYYY-MM-DD')}>
</time> {dayjs().to(dayjs(latestPhoto.date_created))}
</p> </time>
</p>
{/if}
</div> </div>
<div class="ctas"> <div class="ctas">
@@ -258,8 +261,8 @@
props: { props: {
data: data.location[0], data: data.location[0],
photos: data.photos, photos: data.photos,
totalPhotos: locationPhotosCount.count.id, totalPhotos: data.photos.length ? locationPhotosCount.count.id : 0,
lastUpdated: data.photos[0].date_created, lastUpdated: data.photos.length ? data.photos[0].date_created : undefined,
} }
} }
} }