fix(web): album ordering resets to stale order after opening asset viewer

Change album state from $derived to $state so local updates to album.order
are not overwritten when SvelteKit re-fetches page data after navigating
away from and back to the album (e.g. closing the asset viewer).

An effect keeps album in sync with data.album when the album ID changes,
so navigation between albums still works correctly.

Fixes #28383
pull/28719/head
Alexander Chen 2026-05-30 22:47:35 -07:00
parent c42cea5ca9
commit 0b2055ca26
1 changed files with 8 additions and 1 deletions

View File

@ -206,7 +206,14 @@
}
});
let album = $derived(data.album);
let album = $state(data.album);
$effect(() => {
const newAlbum = data.album;
if (newAlbum.id !== album.id) {
album = newAlbum;
}
});
let albumId = $derived(album.id);
const containsEditors = $derived(album?.shared && album.albumUsers.some(({ role }) => role === AlbumUserRole.Editor));