From e5d798581cd7ae3914e4ad1865d83eb7919ad654 Mon Sep 17 00:00:00 2001 From: Zlendy Date: Sun, 22 Jan 2023 04:26:58 +0100 Subject: [PATCH] fix(web): update album information when sliding images (#1378) --- .../components/asset-viewer/asset-viewer.svelte | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/web/src/lib/components/asset-viewer/asset-viewer.svelte b/web/src/lib/components/asset-viewer/asset-viewer.svelte index 4b0e58c801..7439caac51 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer.svelte @@ -36,17 +36,23 @@ onMount(async () => { document.addEventListener('keydown', onKeyboardPress); + getAllAlbums(); + }); + + onDestroy(() => { + document.removeEventListener('keydown', onKeyboardPress); + }); + + $: asset.id && getAllAlbums(); // Update the album information when the asset ID changes + + const getAllAlbums = async () => { try { const { data } = await api.albumApi.getAllAlbums(undefined, asset.id); appearsInAlbums = data; } catch (e) { console.error('Error getting album that asset belong to', e); } - }); - - onDestroy(() => { - document.removeEventListener('keydown', onKeyboardPress); - }); + } const handleKeyboardPress = (key: string) => { switch (key) {