Handle potential null response on genre results from Navidrome

This commit is contained in:
jeffvli 2024-09-26 12:13:03 -07:00
parent c96f5b207d
commit 244aee45cd
2 changed files with 6 additions and 6 deletions

View File

@ -99,7 +99,7 @@ const normalizeSong = (
item.rgAlbumGain || item.rgTrackGain
? { album: item.rgAlbumGain, track: item.rgTrackGain }
: null,
genres: item.genres?.map((genre) => ({
genres: (item.genres || []).map((genre) => ({
id: genre.id,
imageUrl: null,
itemType: LibraryItem.GENRE,
@ -162,7 +162,7 @@ const normalizeAlbum = (
comment: item.comment || null,
createdAt: item.createdAt.split('T')[0],
duration: item.duration * 1000 || null,
genres: item.genres?.map((genre) => ({
genres: (item.genres || []).map((genre) => ({
id: genre.id,
imageUrl: null,
itemType: LibraryItem.GENRE,
@ -221,7 +221,7 @@ const normalizeAlbumArtist = (
backgroundImageUrl: null,
biography: item.biography || null,
duration: null,
genres: item.genres?.map((genre) => ({
genres: (item.genres || []).map((genre) => ({
id: genre.id,
imageUrl: null,
itemType: LibraryItem.GENRE,

View File

@ -76,7 +76,7 @@ const albumArtist = z.object({
externalInfoUpdatedAt: z.string(),
externalUrl: z.string(),
fullText: z.string(),
genres: z.array(genre),
genres: z.array(genre).nullable(),
id: z.string(),
largeImageUrl: z.string().optional(),
mbzArtistId: z.string().optional(),
@ -116,7 +116,7 @@ const album = z.object({
duration: z.number(),
fullText: z.string(),
genre: z.string(),
genres: z.array(genre),
genres: z.array(genre).nullable(),
id: z.string(),
maxYear: z.number(),
mbzAlbumArtistId: z.string().optional(),
@ -180,7 +180,7 @@ const song = z.object({
externalUrl: z.string().optional(),
fullText: z.string(),
genre: z.string(),
genres: z.array(genre),
genres: z.array(genre).nullable(),
hasCoverArt: z.boolean(),
id: z.string(),
imageFiles: z.string().optional(),