From 8fbff071eac4cc23bc49220c72a5cb9e7400ec7e Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Wed, 15 Jul 2026 02:13:55 +0000 Subject: [PATCH] fix: playlists in recently played throw errors (#11) --------- Co-authored-by: Rem Helper Reviewed-on: https://git.abunchofknowitalls.com/joshuafhiggins/otunes/pulls/11 --- packages/convex/convex/library.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/convex/convex/library.ts b/packages/convex/convex/library.ts index 145fdfd..6746306 100644 --- a/packages/convex/convex/library.ts +++ b/packages/convex/convex/library.ts @@ -785,18 +785,26 @@ async function browseRecentlyPlayedItems(ctx: QueryCtx) { const items: (BrowseAlbum | PlaylistSummary)[] = [] for (const id of recentlyPlayed) { - const album = await ctx.db.get("albums", id as Id<"albums">) - if (album) { - const artist = artistMap.get(album.artist) - if (artist) { - items.push(toBrowseAlbum(album, artist)) + const albumId = ctx.db.normalizeId("albums", id) + if (albumId !== null) { + const album = await ctx.db.get("albums", albumId) + if (album) { + const artist = artistMap.get(album.artist) + if (artist) { + items.push(toBrowseAlbum(album, artist)) + } } continue } - const playlist = await ctx.db.get("playlists", id as Id<"playlists">) + const playlistId = ctx.db.normalizeId("playlists", id) + if (playlistId === null) { + continue + } + + const playlist = await ctx.db.get("playlists", playlistId) if (playlist) { - const owner = await ctx.db.get(playlist.owner) + const owner = await ctx.db.get("users", playlist.owner) items.push({ id: playlist._id, title: playlist.name,