fix(spa): playlist tree tolerates a single group's fetch failure (#153 review)

Use Promise.allSettled when loading each group's playlists so one group's
transient error shows that group empty rather than blanking the whole tree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-08 21:24:50 +02:00
co-authored by Claude Opus 4.8
parent 59edec1e85
commit a6064eccb2
+5 -2
View File
@@ -804,10 +804,13 @@ function usePlaylistTreeData() {
const load = useCallback(() => {
getPlaylistGroups()
.then(async (groups) => {
const lists = await Promise.all(groups.map((group) => getPlaylists(group.id)));
// allSettled so one group's transient fetch failure shows that group empty
// rather than blanking the whole tree.
const lists = await Promise.allSettled(groups.map((group) => getPlaylists(group.id)));
const playlists: Record<number, Playlist[]> = {};
groups.forEach((group, index) => {
playlists[group.id] = lists[index];
const result = lists[index];
playlists[group.id] = result.status === 'fulfilled' ? result.value : [];
});
return { groups, playlists };
})