From 243d22822ae5bbe4eb56884d68576df9b4db8dc3 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Wed, 11 Feb 2026 15:13:42 +0100 Subject: [PATCH] Add hide feature to profile page --- web/components/profile-grid.tsx | 33 +++------ web/components/profile/profile-header.tsx | 6 +- .../widgets/hide-profile-button.tsx | 71 +++++++++++++++++++ 3 files changed, 83 insertions(+), 27 deletions(-) create mode 100644 web/components/widgets/hide-profile-button.tsx diff --git a/web/components/profile-grid.tsx b/web/components/profile-grid.tsx index 725e6d4..dde371a 100644 --- a/web/components/profile-grid.tsx +++ b/web/components/profile-grid.tsx @@ -13,10 +13,7 @@ import {useUser} from "web/hooks/use-user"; import {useT} from "web/lib/locale"; import {useAllChoices} from "web/hooks/use-choices"; import {getSeekingGenderText} from "web/lib/profile/seeking"; -import {Tooltip} from 'web/components/widgets/tooltip' -import {EyeOffIcon} from '@heroicons/react/outline' -import {useState} from 'react' -import {api} from 'web/lib/api' +import HideProfileButton from 'web/components/widgets/hide-profile-button' export const ProfileGrid = (props: { profiles: Profile[] @@ -95,7 +92,6 @@ function ProfilePreview(props: { const choicesIdsToLabels = useAllChoices() const t = useT() // const currentUser = useUser() - const [hiding, setHiding] = useState(false) const bio = profile.bio as JSONContent; @@ -170,26 +166,13 @@ function ProfilePreview(props: { )} {/* Hide profile button */} {onHide && ( - - - + )} diff --git a/web/components/profile/profile-header.tsx b/web/components/profile/profile-header.tsx index 8115ca8..05a4ede 100644 --- a/web/components/profile/profile-header.tsx +++ b/web/components/profile/profile-header.tsx @@ -23,6 +23,7 @@ import {StarButton} from "web/components/widgets/star-button"; import {disableProfile} from "web/lib/util/disable"; import {useT} from 'web/lib/locale' import {Tooltip} from "web/components/widgets/tooltip"; +import HideProfileButton from 'web/components/widgets/hide-profile-button' export default function ProfileHeader(props: { user: User @@ -153,8 +154,9 @@ export default function ProfileHeader(props: { ) : ( - {/*TODO: Add score to profile page once we can efficiently compute it (i.e., not recomputing it for every profile)*/} - {/**/} + {currentUser && !isCurrentUser && ( + + )} void + className?: string + iconClassName?: string + tooltip?: string + ariaLabel?: string + stopPropagation?: boolean + suppressToast?: boolean +} + +export function HideProfileButton(props: HideProfileButtonProps) { + const { + hiddenUserId, + onHidden, + className, + iconClassName, + tooltip, + ariaLabel, + stopPropagation, + suppressToast, + } = props + + const t = useT() + const [submitting, setSubmitting] = useState(false) + + const onClick = async (e: React.MouseEvent) => { + e.preventDefault() + if (stopPropagation) e.stopPropagation() + if (submitting) return + setSubmitting(true) + try { + await api('hide-profile', {hiddenUserId}) + onHidden?.(hiddenUserId) + if (!suppressToast) + toast.success( + t( + 'profiles.hidden_success', + 'Profile hidden. You will no longer see this person in search results.' + ) + ) + } finally { + setSubmitting(false) + } + } + + return ( + + + + ) +} + +export default HideProfileButton