Improve itemHelper: Improve final datastructure
This commit is contained in:
parent
ce604b3626
commit
d6731d1676
|
@ -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;
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue