From 66c803381a2691794f5308d5e575e3a217edd207 Mon Sep 17 00:00:00 2001 From: Dean Moses Date: Tue, 3 Jan 2023 00:06:53 -0800 Subject: [PATCH] More fixing up of TypeScript complaints about undefined --- src/lib/components/pages/album/day/DayAlbumEditPage.svelte | 6 +++++- src/routes/+layout.svelte | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/components/pages/album/day/DayAlbumEditPage.svelte b/src/lib/components/pages/album/day/DayAlbumEditPage.svelte index 3a0cecd..6947bd6 100644 --- a/src/lib/components/pages/album/day/DayAlbumEditPage.svelte +++ b/src/lib/components/pages/album/day/DayAlbumEditPage.svelte @@ -27,7 +27,11 @@ const imagePath = e.detail.path; console.log(`: thumbnail ${imagePath}`, e.detail); const imageLeafPath = getLeafItemOnPath(imagePath); - setAlbumThumbnail(album.path, imageLeafPath); + if (imageLeafPath) { + setAlbumThumbnail(album.path, imageLeafPath); + } else { + console.error(`: can't find leaf item on thumbnail ${imagePath}`); + } } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index c87138c..3ebd253 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -32,7 +32,7 @@ * @param path path to album */ function getAlbum(path: string): Album | undefined { - return albumStore.getFromInMemory(path).album; + return albumStore.getFromInMemory(path)?.album ?? undefined; }