From d6731d1676096f4108090799423b409cbff4fc4e Mon Sep 17 00:00:00 2001 From: Nikhil Nawgiri Date: Sat, 26 Oct 2024 17:57:05 +0200 Subject: [PATCH] Improve itemHelper: Improve final datastructure --- be/src/itemHelper.ts | 47 +++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/be/src/itemHelper.ts b/be/src/itemHelper.ts index 9da4d03..4497ba4 100644 --- a/be/src/itemHelper.ts +++ b/be/src/itemHelper.ts @@ -1,4 +1,4 @@ -interface Item { +interface ItemProvidedByJellyfin { Name: string, ServerId: string, Id: string, @@ -24,25 +24,36 @@ interface Item { MediaType: string, }; +interface ItemForWishlistUsage { + name: string, + hasSubtitles: boolean, + ageRating: string, + productionYear: number, + itemType: "Movie" | "Series", + imdbId: string, +}; + export const transformItems = (items: []) => ( - items.map((item: Item) => { - // omit unnecessary props + items.map((item: ItemProvidedByJellyfin) => { const { - ServerId, - Id, - Container, - PremiereDate, - CriticRating, - ChannelId, - CommunityRating, - RunTimeTicks, - IsFolder, - VideoType, - ImageBlurHashes, - LocationType, - MediaType, - ...remainingProps + Name, + HasSubtitles, + OfficialRating, + ProductionYear, + Type, + ProviderIds, } = item; - return remainingProps; + const { Imdb } = ProviderIds; + + const newItem: ItemForWishlistUsage = { + name: Name, + hasSubtitles: HasSubtitles, + ageRating: OfficialRating, + productionYear: ProductionYear, + itemType: Type, + imdbId: Imdb, + }; + + return newItem; }) );