From e0f96cea0d3a978bb214c2a9caee52338e2e56a6 Mon Sep 17 00:00:00 2001 From: sai80082 Date: Sun, 1 Dec 2024 22:11:02 +0530 Subject: [PATCH 1/9] fix: thershold option and fix hide person --- src/components/people/PersonItem.tsx | 16 ++++++------ src/components/people/PersonMergeDropdown.tsx | 25 ++++++++++++++++++- src/handlers/api/people.handler.ts | 5 ++-- src/pages/api/people/[id]/similar-faces.ts | 6 +++-- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/components/people/PersonItem.tsx b/src/components/people/PersonItem.tsx index 96cea2f..cd19efa 100644 --- a/src/components/people/PersonItem.tsx +++ b/src/components/people/PersonItem.tsx @@ -10,7 +10,7 @@ import { ArrowUpRight, Info, Search } from "lucide-react"; import { useConfig } from "@/contexts/ConfigContext"; import { useToast } from "../ui/use-toast"; import { Badge } from "../ui/badge"; - +import { Button } from "@/components/ui/button"; interface IProps { person: IPerson; onRemove: (person: IPerson) => void; @@ -78,18 +78,11 @@ export default function PersonItem({ person, onRemove }: IProps) { )} >
-
{ - handleHide(!formData.isHidden); - }} - > -
-
{person.assetCount} Assets
@@ -108,8 +101,13 @@ export default function PersonItem({ person, onRemove }: IProps) {
-
+
+
{!editMode ? ( diff --git a/src/components/people/PersonMergeDropdown.tsx b/src/components/people/PersonMergeDropdown.tsx index 4811c47..ec30a12 100644 --- a/src/components/people/PersonMergeDropdown.tsx +++ b/src/components/people/PersonMergeDropdown.tsx @@ -56,6 +56,7 @@ export function PersonMergeDropdown({ const [selectedPeople, setSelectedPeople] = useState([]); const [primaryPerson, setPrimaryPerson] = useState(person); const [merging, setMerging] = useState(false); + const [threshold, setThreshold] = useState(0.5); const { toast } = useToast(); const selectedIds = useMemo( @@ -89,7 +90,7 @@ export function PersonMergeDropdown({ }; const fetchSuggestions = () => { - return listSimilarFaces(person.id) + return listSimilarFaces(person.id, threshold) .then(setSimilarPeople) .catch(() => { toast({ @@ -161,6 +162,13 @@ export function PersonMergeDropdown({ setSelectedPeople(newSelected); }; + useEffect(() => { + if (open) { + setSimilarLoading(true); + fetchSuggestions(); + } + }, [threshold, open]); + useEffect(() => { if (open && !similarPeople.length) fetchSuggestions(); }, [open, person.id, similarPeople]); @@ -279,6 +287,21 @@ export function PersonMergeDropdown({ handleSearch(e.target.value); }} /> +
+ + setThreshold(parseFloat(e.target.value))} + placeholder="Threshold (0 to 1)" + className="mt-2" + /> +
{selectedPeople.length > 0 ? (
diff --git a/src/handlers/api/people.handler.ts b/src/handlers/api/people.handler.ts index 5c42d5a..7e85646 100644 --- a/src/handlers/api/people.handler.ts +++ b/src/handlers/api/people.handler.ts @@ -39,6 +39,7 @@ export const mergePerson = (id: string, targetIds: string[]) => { return API.post(MERGE_PERSON_PATH(id), { ids: targetIds }) } -export const listSimilarFaces = (id: string) => { - return API.get(SIMILAR_FACES_PATH(id)).then((response) => response.map((person: any) => cleanUpPerson(person, true))); +export const listSimilarFaces = (id: string, threshold: number) => { + return API.get(SIMILAR_FACES_PATH(id), { threshold: threshold }) + .then((response) => response.map((person: any) => cleanUpPerson(person, true))); } \ No newline at end of file diff --git a/src/pages/api/people/[id]/similar-faces.ts b/src/pages/api/people/[id]/similar-faces.ts index e1466b7..32741d3 100644 --- a/src/pages/api/people/[id]/similar-faces.ts +++ b/src/pages/api/people/[id]/similar-faces.ts @@ -18,6 +18,7 @@ interface IQuery { minimumAssetCount: number; sort: ISortField; sortOrder: "asc" | "desc"; + threshold?: number; } export default async function handler( req: NextApiRequest, @@ -26,9 +27,10 @@ export default async function handler( try { const { id, + threshold = 0.5, } = req.query as any as IQuery; - const currentUser = await getCurrentUser(req); + const currentUser = await getCurrentUser(req); const personRecords = await db .select() .from(person) @@ -92,7 +94,7 @@ export default async function handler( and( ne(person.id, id), eq(person.ownerId, currentUser.id), - gt(similarity, 0.5) + gt(similarity, threshold) ) ) .limit(12); From db312003fccee7004da873c67838bd278e2d91b6 Mon Sep 17 00:00:00 2001 From: knom Date: Sun, 15 Dec 2024 12:28:59 +0100 Subject: [PATCH 2/9] removed videos filter --- src/pages/api/assets/missing-location-dates.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/api/assets/missing-location-dates.ts b/src/pages/api/assets/missing-location-dates.ts index 831731b..c09692a 100644 --- a/src/pages/api/assets/missing-location-dates.ts +++ b/src/pages/api/assets/missing-location-dates.ts @@ -31,7 +31,6 @@ export default async function handler( isNull(exif.latitude), isNotNull(assets.createdAt), isNotNull(exif.dateTimeOriginal), - eq(assets.type, "VIDEO"), eq(assets.ownerId, currentUser.id), eq(assets.isVisible, true), )) From 5c9434c629400bc794bf62f45dd55b4508c7f42a Mon Sep 17 00:00:00 2001 From: Jack Brown <6218551+jackbrown1993@users.noreply.github.com> Date: Sun, 15 Dec 2024 23:22:53 +0000 Subject: [PATCH 3/9] Add 'Select All' button to Merge People page. --- src/components/people/PersonMergeDropdown.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/people/PersonMergeDropdown.tsx b/src/components/people/PersonMergeDropdown.tsx index 4811c47..93f5196 100644 --- a/src/components/people/PersonMergeDropdown.tsx +++ b/src/components/people/PersonMergeDropdown.tsx @@ -114,8 +114,6 @@ export function PersonMergeDropdown({ } }; - - const handleMerge = () => { if (selectedPeople.length === 0) { return; @@ -227,7 +225,10 @@ export function PersonMergeDropdown({ return ( - @@ -312,6 +313,15 @@ export function PersonMergeDropdown({ {renderContent()} + + - + Tag Missing Location @@ -63,7 +63,7 @@ export default function TagMissingLocationDialog({ onOpenChange={setOpen} location={mapPosition} onLocationChange={setMapPosition} /> -
+
diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index 5d16351..01d7e92 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -27,9 +27,14 @@ const DialogOverlay = React.forwardRef< )) DialogOverlay.displayName = DialogPrimitive.Overlay.displayName +interface DialogContentProps extends React.ComponentPropsWithoutRef { + className?: string; + children?: React.ReactNode; +} + const DialogContent = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef + DialogContentProps >(({ className, children, ...props }, ref) => (