Improve itemHelper: Improve final datastructure

This commit is contained in:
Nikhil Nawgiri 2024-10-26 17:57:05 +02:00
parent ce604b3626
commit d6731d1676

View file

@ -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;
})
);