mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
optimize gathering album art a bit
This commit is contained in:
@@ -55,11 +55,20 @@ export const createMusicMapSlice = (set: SetState<Store>, get: GetState<Store>):
|
||||
},
|
||||
|
||||
mapChildrenToSongs: async (children, coverArt) => {
|
||||
const songMaps: Promise<Song>[] = []
|
||||
const albumIds = children.reduce((acc, val) => {
|
||||
if (val.albumId && !(val.albumId in acc)) {
|
||||
acc[val.albumId] = get().getAlbumCoverArt(val.albumId)
|
||||
}
|
||||
return acc
|
||||
}, {} as Record<string, Promise<string | undefined>>)
|
||||
|
||||
await Promise.all(Object.values(albumIds))
|
||||
|
||||
const songs: Song[] = []
|
||||
for (const child of children) {
|
||||
songMaps.push(get().mapChildToSong(child, coverArt))
|
||||
songs.push(await get().mapChildToSong(child, coverArt || (await get().getAlbumCoverArt(child.albumId))))
|
||||
}
|
||||
return await Promise.all(songMaps)
|
||||
return songs
|
||||
},
|
||||
|
||||
mapArtistID3toArtist: artist => {
|
||||
|
||||
Reference in New Issue
Block a user