From f3ba994186fafb47916f9801ce931051bd7b6ee5 Mon Sep 17 00:00:00 2001 From: Antonio Sarro <tech@antoniosarro.dev> Date: Wed, 29 Jan 2025 18:27:30 +0100 Subject: [PATCH] fix(web): update recent album after edit (#15762) * fix(web): update recent album after edit * chore: clean up --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> --- web/src/lib/components/album-page/albums-list.svelte | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/web/src/lib/components/album-page/albums-list.svelte b/web/src/lib/components/album-page/albums-list.svelte index 178190dc340b4..0696a937ccc7d 100644 --- a/web/src/lib/components/album-page/albums-list.svelte +++ b/web/src/lib/components/album-page/albums-list.svelte @@ -35,6 +35,7 @@ locale, type AlbumViewSettings, } from '$lib/stores/preferences.store'; + import { userInteraction } from '$lib/stores/user.svelte'; import { goto } from '$app/navigation'; import { AppRoute } from '$lib/constants'; import { t } from 'svelte-i18n'; @@ -293,6 +294,15 @@ sharedAlbums[sharedAlbums.findIndex(({ id }) => id === album.id)] = album; }; + const updateRecentAlbumInfo = (album: AlbumResponseDto) => { + for (const cachedAlbum of userInteraction.recentAlbums || []) { + if (cachedAlbum.id === album.id) { + Object.assign(cachedAlbum, { ...cachedAlbum, ...album }); + break; + } + } + }; + const successEditAlbumInfo = (album: AlbumResponseDto) => { albumToEdit = null; @@ -308,6 +318,7 @@ }); updateAlbumInfo(album); + updateRecentAlbumInfo(album); }; const handleAddUsers = async (albumUsers: AlbumUserAddDto[]) => {