Sfoglia il codice sorgente

fix(web): update album information when sliding images (#1378)

Zlendy 2 anni fa
parent
commit
e5d798581c
1 ha cambiato i file con 11 aggiunte e 5 eliminazioni
  1. 11 5
      web/src/lib/components/asset-viewer/asset-viewer.svelte

+ 11 - 5
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) {