Skip to content

Commit

Permalink
fix navi null date (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgarner7 authored Dec 13, 2023
1 parent a8814d3 commit c05b474
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/renderer/api/navidrome/navidrome-normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ const getCoverArtUrl = (args: {
);
};

interface WithDate {
playDate?: string;
}

const normalizePlayDate = (item: WithDate): string | null => {
return !item.playDate || item.playDate.includes('0001-') ? null : item.playDate;
};

const normalizeSong = (
item: z.infer<typeof ndType._response.song> | z.infer<typeof ndType._response.playlistSong>,
server: ServerListItem | null,
Expand Down Expand Up @@ -100,7 +108,7 @@ const normalizeSong = (
imagePlaceholderUrl,
imageUrl,
itemType: LibraryItem.SONG,
lastPlayedAt: item.playDate.includes('0001-') ? null : item.playDate,
lastPlayedAt: normalizePlayDate(item),
lyrics: item.lyrics ? item.lyrics : null,
name: item.title,
path: item.path,
Expand Down Expand Up @@ -159,7 +167,7 @@ const normalizeAlbum = (
imageUrl,
isCompilation: item.compilation,
itemType: LibraryItem.ALBUM,
lastPlayedAt: item.playDate.includes('0001-') ? null : item.playDate,
lastPlayedAt: normalizePlayDate(item),
name: item.name,
playCount: item.playCount,
releaseDate: new Date(item.minYear, 0, 1).toISOString(),
Expand Down Expand Up @@ -207,7 +215,7 @@ const normalizeAlbumArtist = (
id: item.id,
imageUrl: imageUrl || null,
itemType: LibraryItem.ALBUM_ARTIST,
lastPlayedAt: item.playDate.includes('0001-') ? null : item.playDate,
lastPlayedAt: normalizePlayDate(item),
name: item.name,
playCount: item.playCount,
serverId: server?.id || 'unknown',
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/api/navidrome/navidrome-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const albumArtist = z.object({
name: z.string(),
orderArtistName: z.string(),
playCount: z.number(),
playDate: z.string(),
playDate: z.string().optional(),
rating: z.number(),
size: z.number(),
smallImageUrl: z.string().optional(),
Expand Down Expand Up @@ -128,7 +128,7 @@ const album = z.object({
orderAlbumArtistName: z.string(),
orderAlbumName: z.string(),
playCount: z.number(),
playDate: z.string(),
playDate: z.string().optional(),
rating: z.number().optional(),
size: z.number(),
songCount: z.number(),
Expand Down Expand Up @@ -211,7 +211,7 @@ const song = z.object({
orderTitle: z.string(),
path: z.string(),
playCount: z.number(),
playDate: z.string(),
playDate: z.string().optional(),
rating: z.number().optional(),
rgAlbumGain: z.number().optional(),
rgAlbumPeak: z.number().optional(),
Expand Down

1 comment on commit c05b474

@vercel
Copy link

@vercel vercel bot commented on c05b474 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

feishin – ./

feishin.vercel.app
feishin-git-development-jeffvli.vercel.app
feishin-jeffvli.vercel.app

Please sign in to comment.