From b3d8a1c8a65f2ca3341db1931da681b4d0a00df3 Mon Sep 17 00:00:00 2001 From: Gauvain Date: Sun, 31 May 2026 23:46:47 +0200 Subject: [PATCH] refactor(item): dedupe top people by id Jellyfin can list the same person multiple times (e.g. credited as both actor and writer). Dedupe by Id when picking the top 3 so the same actor section is not rendered twice. --- components/item/ItemPeopleSections.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/components/item/ItemPeopleSections.tsx b/components/item/ItemPeopleSections.tsx index 0b16271fc..456276da2 100644 --- a/components/item/ItemPeopleSections.tsx +++ b/components/item/ItemPeopleSections.tsx @@ -37,7 +37,20 @@ export const ItemPeopleSections: React.FC = ({ item, ...props }) => { return { ...item, People: people } as BaseItemDto; }, [item, people]); - const topPeople = useMemo(() => people.slice(0, 3), [people]); + // Jellyfin can list the same person several times (e.g. an actor also + // credited as writer). Dedupe by Id so the same actor section isn't rendered + // twice and we still surface 3 distinct people. + const topPeople = useMemo(() => { + const seen = new Set(); + const unique: BaseItemPerson[] = []; + for (const person of people) { + if (!person.Id || seen.has(person.Id)) continue; + seen.add(person.Id); + unique.push(person); + if (unique.length >= 3) break; + } + return unique; + }, [people]); const renderActorSection = useCallback( (person: BaseItemPerson, idx: number, total: number) => {