From 44a7ec238f34a7b81c9467864da4f0c8812c689a Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sun, 17 Nov 2024 21:36:13 +0100 Subject: [PATCH] fix: show distinct people --- components/series/CastAndCrew.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/components/series/CastAndCrew.tsx b/components/series/CastAndCrew.tsx index 5e4ec379..a19cfc30 100644 --- a/components/series/CastAndCrew.tsx +++ b/components/series/CastAndCrew.tsx @@ -6,7 +6,7 @@ import { } from "@jellyfin/sdk/lib/generated-client/models"; import { router } from "expo-router"; import { useAtom } from "jotai"; -import React from "react"; +import React, { useMemo } from "react"; import { TouchableOpacity, View, ViewProps } from "react-native"; import { HorizontalScroll } from "../common/HorrizontalScroll"; import { Text } from "../common/Text"; @@ -20,19 +20,32 @@ interface Props extends ViewProps { export const CastAndCrew: React.FC = ({ item, loading, ...props }) => { const [api] = useAtom(apiAtom); + const destinctPeople = useMemo(() => { + const people: BaseItemPerson[] = []; + item?.People?.forEach((person) => { + const existingPerson = people.find((p) => p.Id === person.Id); + if (existingPerson) { + existingPerson.Role = `${existingPerson.Role}, ${person.Role}`; + } else { + people.push(person); + } + }); + return people; + }, [item?.People]); + return ( Cast & Crew ( { router.push(`/actors/${item.Id}`); }} - key={item.Id} + key={index} className="flex flex-col w-28" >