fix(web): refresh recent albums sidebar after album changes (#26757)

This commit is contained in:
Michel Heusschen
2026-03-09 17:11:32 +01:00
committed by GitHub
parent df0c86920d
commit a47b232235
10 changed files with 37 additions and 21 deletions

View File

@@ -3,17 +3,12 @@
import { userInteraction } from '$lib/stores/user.svelte';
import { getAssetMediaUrl } from '$lib/utils';
import { handleError } from '$lib/utils/handle-error';
import { getAllAlbums, type AlbumResponseDto } from '@immich/sdk';
import { onMount } from 'svelte';
import { getAllAlbums } from '@immich/sdk';
import { t } from 'svelte-i18n';
let albums: AlbumResponseDto[] = $state([]);
let albums = $state(userInteraction.recentAlbums);
onMount(async () => {
if (userInteraction.recentAlbums) {
albums = userInteraction.recentAlbums;
return;
}
const refreshAlbums = async () => {
try {
const allAlbums = await getAllAlbums({});
albums = allAlbums.sort((a, b) => (a.updatedAt > b.updatedAt ? -1 : 1)).slice(0, 3);
@@ -21,6 +16,12 @@
} catch (error) {
handleError(error, $t('failed_to_load_assets'));
}
};
$effect(() => {
if (!userInteraction.recentAlbums) {
void refreshAlbums();
}
});
</script>