From 213c679cae8a51e15388d48a67a9782d4c9ea3b1 Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Mon, 16 Dec 2024 08:41:54 -0600 Subject: [PATCH] fix(web): navigation bar layout shift when recent albums are opened --- .../side-bar/recent-albums.svelte | 64 ++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/web/src/lib/components/shared-components/side-bar/recent-albums.svelte b/web/src/lib/components/shared-components/side-bar/recent-albums.svelte index d90d7dec01..ccd0de62ee 100644 --- a/web/src/lib/components/shared-components/side-bar/recent-albums.svelte +++ b/web/src/lib/components/shared-components/side-bar/recent-albums.svelte @@ -2,37 +2,55 @@ import { onMount } from 'svelte'; import { getAssetThumbnailUrl } from '$lib/utils'; import { getAllAlbums, type AlbumResponseDto } from '@immich/sdk'; - import { handleError } from '$lib/utils/handle-error'; - import { t } from 'svelte-i18n'; let albums: AlbumResponseDto[] = $state([]); - onMount(async () => { + let loadingAlbums: boolean = $state(false); + + async function loadAlbums() { try { + loadingAlbums = true; const allAlbums = await getAllAlbums({}); albums = allAlbums.sort((a, b) => (a.updatedAt > b.updatedAt ? -1 : 1)).slice(0, 3); } catch (error) { - handleError(error, $t('failed_to_load_assets')); + console.error('Failed to load albums', error); + } finally { + loadingAlbums = false; } - }); + } + + onMount(loadAlbums); -{#each albums as album} - -
-
+{#if !loadingAlbums} + {#each albums as album} +
+
+
+
+
+ {album.albumName} +
+
+ {/each} +{:else} + {#each { length: 3 } as _} +
+
+
+
+
-
- {album.albumName} -
- -{/each} + {/each} +{/if}