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

View file

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