mirror of
https://github.com/immich-app/immich.git
synced 2026-03-23 17:09:51 +03:00
fix(web): refresh recent albums sidebar after album changes (#26757)
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user