From 6259481d3ebe6fa29e4ef1defa0055800b26a548 Mon Sep 17 00:00:00 2001 From: Varun Raj Date: Wed, 29 Oct 2025 22:35:38 +0530 Subject: [PATCH] feat: enhance person merging functionality with name filtering - Updated the `listSimilarFaces` API to accept a name parameter for filtering results. - Modified the `PersonMergeDropdown` component to include a new select input for choosing between "nameless", "tagged", and "all" options. - Adjusted the API handler to filter similar faces based on the selected name criteria. - Improved the UI layout for the threshold and name selection inputs. --- src/components/people/PersonMergeDropdown.tsx | 33 +++++++++++++++---- src/handlers/api/people.handler.ts | 9 +++-- src/pages/api/people/[id]/similar-faces.ts | 14 ++++++-- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/components/people/PersonMergeDropdown.tsx b/src/components/people/PersonMergeDropdown.tsx index 9fd9959..4a8bab0 100644 --- a/src/components/people/PersonMergeDropdown.tsx +++ b/src/components/people/PersonMergeDropdown.tsx @@ -33,6 +33,8 @@ import { CaretDownIcon } from "@radix-ui/react-icons"; import FaceThumbnail from "./merge/FaceThumbnail"; import ErrorBlock from "../shared/ErrorBlock"; import { cn } from "@/lib/utils"; +import { Label } from "../ui/label"; +import { Select, SelectItem, SelectContent, SelectTrigger, SelectValue } from "../ui/select"; interface PersonMergeDropdownProps { person: IPerson; @@ -57,6 +59,7 @@ export function PersonMergeDropdown({ const [primaryPerson, setPrimaryPerson] = useState(person); const [merging, setMerging] = useState(false); const [threshold, setThreshold] = useState(0.5); + const [name, setName] = useState<"nameless" | "tagged">("tagged"); const { toast } = useToast(); const selectedIds = useMemo( @@ -90,7 +93,7 @@ export function PersonMergeDropdown({ }; const fetchSuggestions = () => { - return listSimilarFaces(person.id, threshold) + return listSimilarFaces(person.id, { threshold, name: name }) .then(setSimilarPeople) .catch(() => { toast({ @@ -168,11 +171,11 @@ export function PersonMergeDropdown({ setSimilarLoading(true); fetchSuggestions(); } - }, [threshold, open]); + }, [threshold, name, open]); useEffect(() => { if (open && !similarPeople.length) fetchSuggestions(); - }, [open, person.id, similarPeople]); + }, [open, person.id, similarPeople, threshold, name]); useEffect(() => { setPrimaryPerson(person); @@ -291,10 +294,11 @@ export function PersonMergeDropdown({ handleSearch(e.target.value); }} /> -
-