From 0130115be88eae07b3a0fb3b636e49281898bc34 Mon Sep 17 00:00:00 2001 From: Manuel <30572287+manuel-rw@users.noreply.github.com> Date: Sun, 26 Mar 2023 00:59:20 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20missing=20remote=20images?= =?UTF-8?q?=20for=20albums=20(#131)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/search/AlbumSearchHint.ts | 13 ++++++++++--- src/models/search/SearchHint.ts | 5 +---- src/models/shared/Track.ts | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) 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,