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:
@@ -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 };
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user