mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 01:11:36 +03:00
fix: reduce the number of API requests when changing route (#14666)
* fix: reduce the number of API requests when changing route * fix: reset `userInteraction` after sign out
This commit is contained in:
@@ -4,13 +4,19 @@
|
||||
import { getAllAlbums, type AlbumResponseDto } from '@immich/sdk';
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { t } from 'svelte-i18n';
|
||||
import { userInteraction } from '$lib/stores/user.svelte';
|
||||
|
||||
let albums: AlbumResponseDto[] = $state([]);
|
||||
|
||||
onMount(async () => {
|
||||
if (userInteraction.recentAlbums) {
|
||||
albums = userInteraction.recentAlbums;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const allAlbums = await getAllAlbums({});
|
||||
albums = allAlbums.sort((a, b) => (a.updatedAt > b.updatedAt ? -1 : 1)).slice(0, 3);
|
||||
userInteraction.recentAlbums = albums;
|
||||
} catch (error) {
|
||||
handleError(error, $t('failed_to_load_assets'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user