Skip to content

Commit

Permalink
fix: do extra checks for album ids in
Browse files Browse the repository at this point in the history
  • Loading branch information
leinelissen committed May 25, 2024
1 parent 24b5a47 commit 00675bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/store/music/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ AsyncThunkAPI

const albums = await Promise.all(results.filter((item) => (
!state.music.albums.ids.includes(item.Type === 'MusicAlbum' ? item.Id : item.AlbumId)
&& (item.Type === 'Audio' ? item.AlbumId : true)
)).map(async (item) => {
if (item.Type === 'MusicAlbum') {
return item;
Expand Down
8 changes: 6 additions & 2 deletions src/utility/JellyfinApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,13 @@ export async function searchItem(
}).toString();

const results = await fetch(`${credentials?.uri}/Users/${credentials?.user_id}/Items?${params}`, config)
.then(response => response.json());
.then(response => response.json() as Promise<{ Items: (Album | AlbumTrack)[] }>);

return results.Items;
return results.Items
.filter((item) => (
// GUARD: Ensure that we're either dealing with an album or a track from an album.
item.Type === 'MusicAlbum' || (item.Type === 'Audio' && item.AlbumId)
));
}

const playlistOptions = {
Expand Down

0 comments on commit 00675bb

Please sign in to comment.