diff --git a/src/models/search/AlbumSearchHint.ts b/src/models/search/AlbumSearchHint.ts index 4cec06c..dd4b440 100644 --- a/src/models/search/AlbumSearchHint.ts +++ b/src/models/search/AlbumSearchHint.ts @@ -17,10 +17,17 @@ export class AlbumSearchHint extends SearchHint { override async toTracks( searchService: JellyfinSearchService, ): Promise { + const remoteImages = await searchService.getRemoteImageById(this.id); + const albumItems = await searchService.getAlbumItems(this.id); - const tracks = albumItems.map(async (x) => - (await x.toTracks(searchService)).find((x) => x !== null), + const tracks = await Promise.all( + albumItems.map(async (x) => + (await x.toTracks(searchService)).find((x) => x !== null), + ), ); - return await Promise.all(tracks); + return tracks.map((track): Track => { + track.remoteImages = remoteImages; + return track; + }); } } diff --git a/src/models/search/SearchHint.ts b/src/models/search/SearchHint.ts index 093d45a..016acc4 100644 --- a/src/models/search/SearchHint.ts +++ b/src/models/search/SearchHint.ts @@ -18,10 +18,7 @@ export class SearchHint { } async toTracks(searchService: JellyfinSearchService): Promise { - const remoteImages = await searchService.getRemoteImageById(this.id); - return [ - new Track(this.id, this.name, this.runtimeInMilliseconds, remoteImages), - ]; + return [new Track(this.id, this.name, this.runtimeInMilliseconds, {})]; } getId(): string { diff --git a/src/models/shared/Track.ts b/src/models/shared/Track.ts index 7ef3b7c..b93875f 100644 --- a/src/models/shared/Track.ts +++ b/src/models/shared/Track.ts @@ -25,7 +25,7 @@ export class Track { /** * A result object that contains a collection of images that are available outside the current network. */ - readonly remoteImages?: RemoteImageResult; + remoteImages?: RemoteImageResult; constructor( id: string,