From ac0d3fcb8692a664b89581f5f067bf6c31218c0a Mon Sep 17 00:00:00 2001 From: Uruk Date: Tue, 10 Feb 2026 19:13:44 +0100 Subject: [PATCH] refactor(item): improves top people display logic Improves the logic for displaying the top people in the item sections. The previous implementation simply sliced the people array which could result in duplicate people being displayed. This change ensures that the top people displayed are unique by filtering duplicates based on their id, limiting the number of displayed people to three. --- components/item/ItemPeopleSections.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/item/ItemPeopleSections.tsx b/components/item/ItemPeopleSections.tsx index 0b16271f..2361d254 100644 --- a/components/item/ItemPeopleSections.tsx +++ b/components/item/ItemPeopleSections.tsx @@ -37,7 +37,18 @@ export const ItemPeopleSections: React.FC = ({ item, ...props }) => { return { ...item, People: people } as BaseItemDto; }, [item, people]); - const topPeople = useMemo(() => people.slice(0, 3), [people]); + const topPeople = useMemo(() => { + const seen = new Set(); + const unique: BaseItemPerson[] = []; + for (const person of people) { + if (person.Id && !seen.has(person.Id)) { + seen.add(person.Id); + unique.push(person); + } + if (unique.length >= 3) break; + } + return unique; + }, [people]); const renderActorSection = useCallback( (person: BaseItemPerson, idx: number, total: number) => {