diff --git a/web/components/profile-grid.tsx b/web/components/profile-grid.tsx index dde371a..a017acb 100644 --- a/web/components/profile-grid.tsx +++ b/web/components/profile-grid.tsx @@ -171,7 +171,6 @@ function ProfilePreview(props: { onHidden={onHide} className="ml-2" stopPropagation - suppressToast /> )} diff --git a/web/components/settings/hidden-profiles-modal.tsx b/web/components/settings/hidden-profiles-modal.tsx index 32453a3..0e95113 100644 --- a/web/components/settings/hidden-profiles-modal.tsx +++ b/web/components/settings/hidden-profiles-modal.tsx @@ -1,4 +1,4 @@ -import {useEffect, useMemo, useRef, useState} from 'react' +import {useEffect, useMemo, useState} from 'react' import {Modal, MODAL_CLASS, SCROLLABLE_MODAL_CLASS} from 'web/components/layout/modal' import {Col} from 'web/components/layout/col' import {Row} from 'web/components/layout/row' @@ -30,9 +30,6 @@ export function HiddenProfilesModal(props: { const [error, setError] = useState(null) const [hidden, setHidden] = useState(null) const [busyIds, setBusyIds] = useState>({}) - // Throttle/batch success toasts when unhiding multiple profiles quickly - const [pendingUnhideCount, setPendingUnhideCount] = useState(0) - const toastTimerRef = useRef | null>(null) const empty = useMemo(() => (hidden ? hidden.length === 0 : false), [hidden]) @@ -49,60 +46,20 @@ export function HiddenProfilesModal(props: { .catch((e) => { console.error('Failed to load hidden profiles', e) if (!alive) return - setError( - t( - 'settings.hidden_profiles.load_error', - 'Failed to load hidden profiles.' - ) - ) + setError(t('settings.hidden_profiles.load_error', 'Failed to load hidden profiles.')) }) .finally(() => alive && setLoading(false)) return () => { alive = false - // Reset toast batching state on close/unmount - if (toastTimerRef.current) { - clearTimeout(toastTimerRef.current as number) - toastTimerRef.current = null - } - setPendingUnhideCount(0) } }, [open]) - const flushUnhideToast = () => { - if (pendingUnhideCount <= 0) return - if (pendingUnhideCount === 1) { - toast.success( - t( - 'settings.hidden_profiles.unhidden_success', - 'Profile unhidden. You will start seeing this person again in results.' - ) - ) - } else { - toast.success( - t( - 'settings.hidden_profiles.unhidden_success_many', - 'Unhid {n} profiles.', - // Simple param replacement; if your i18n library supports interpolation, it will use it. - ).replace('{n}', String(pendingUnhideCount)) - ) - } - setPendingUnhideCount(0) - } - const unhide = async (userId: string) => { if (busyIds[userId]) return setBusyIds((b) => ({...b, [userId]: true})) try { await api('unhide-profile', {hiddenUserId: userId}) setHidden((list) => (list ? list.filter((u) => u.id !== userId) : list)) - // Batch/throttle the success toast - setPendingUnhideCount((c) => c + 1) - if (!toastTimerRef.current) { - toastTimerRef.current = setTimeout(() => { - flushUnhideToast() - toastTimerRef.current = null - }, 600) - } } catch (e) { console.error('Failed to unhide profile', e) toast.error(t('settings.hidden_profiles.unhide_failed', 'Failed to unhide')) diff --git a/web/components/widgets/hide-profile-button.tsx b/web/components/widgets/hide-profile-button.tsx index 9c54c0f..2334fa9 100644 --- a/web/components/widgets/hide-profile-button.tsx +++ b/web/components/widgets/hide-profile-button.tsx @@ -1,9 +1,8 @@ import clsx from 'clsx' import {useState} from 'react' -import {EyeOffIcon} from '@heroicons/react/outline' +import {EyeIcon, EyeOffIcon} from '@heroicons/react/outline' import {Tooltip} from 'web/components/widgets/tooltip' import {api} from 'web/lib/api' -import toast from 'react-hot-toast' import {useT} from 'web/lib/locale' export type HideProfileButtonProps = { @@ -14,7 +13,6 @@ export type HideProfileButtonProps = { tooltip?: string ariaLabel?: string stopPropagation?: boolean - suppressToast?: boolean } export function HideProfileButton(props: HideProfileButtonProps) { @@ -26,7 +24,6 @@ export function HideProfileButton(props: HideProfileButtonProps) { tooltip, ariaLabel, stopPropagation, - suppressToast, } = props const t = useT() @@ -42,30 +39,29 @@ export function HideProfileButton(props: HideProfileButtonProps) { 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 ( - + )