From 3b93e5e99432b30475b9fc847f9053d0b35f64b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Sun, 29 Mar 2020 19:40:32 +0200 Subject: [PATCH] Fix error when leaving Viewer The carousel would go to a photo that doesn't exists --- src/organisms/Carousel.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/organisms/Carousel.svelte b/src/organisms/Carousel.svelte index ba43b66..7d8481e 100644 --- a/src/organisms/Carousel.svelte +++ b/src/organisms/Carousel.svelte @@ -121,7 +121,11 @@ // Viewer: Navigate to photo on init and URL change if (viewer) { - page.subscribe(page => goToPhoto(photos.findIndex(photo => photo.slug === page.params.photo))) + page.subscribe(page => { + if (page.path.includes('/viewer/')) { + goToPhoto(photos.findIndex(photo => photo.slug === page.params.photo)) + } + }) } })