Fix bug where error occurs when there are no artists in the library

This commit is contained in:
simojenki
2021-07-31 15:56:29 +10:00
parent 4aa154baa8
commit f036b39524
2 changed files with 77 additions and 2 deletions

View File

@@ -342,6 +342,8 @@ export class Navidrome implements MusicService {
"subsonic-response.album.song",
"subsonic-response.albumList.album",
"subsonic-response.artist.album",
"subsonic-response.artists.index",
"subsonic-response.artists.index.artist",
"subsonic-response.artistInfo.similarArtist",
"subsonic-response.genres.genre",
"subsonic-response.playlist.entry",
@@ -378,7 +380,7 @@ export class Navidrome implements MusicService {
getArtists = (credentials: Credentials): Promise<IdName[]> =>
this.getJSON<GetArtistsResponse>(credentials, "/rest/getArtists")
.then((it) => it.artists.index.flatMap((it) => it.artist || []))
.then((it) => (it.artists.index || []).flatMap((it) => it.artist || []))
.then((artists) =>
artists.map((artist) => ({
id: artist._id,