Files
im_webapp/web/src/app/Toast.tsx
T
Your NameandClaude Sonnet 5 5c3f3b7653 feat(web): complete groups/contacts/favorites/settings/calls/system domains + extensive review-round fixes
Rounds out the full rewrite with the remaining feature domains: group
management (admin panel, mute, files, announcements, QR-based invite/join),
contacts (friend profile, add-friend, blocklist, new-friends), favorites
(real media rendering across text/image/video/voice/file/link), settings
(profile/security/privacy/general/about), calls (Agora-backed audio/video
signaling + call history), and system messages/file assistant.

Also folds in a large batch of live-verified fixes surfaced by repeated
fresh code-review passes and hands-on E2E testing against the real
backend, including: WS reconnect not resubscribing any topic after a
disconnect, missing x-im-client-mid on every send path (protocol
compliance for retry dedup), group mute/member-settings/self-profile
endpoint corrections, relationship-state type fixes across search/QR/
friend-profile, tenant-switch logout gap, password-policy now read from
the real per-tenant config instead of guessed, NavRail highlight/
aria-current desync, several call-state-machine races, and responsive
layout fixes across all four breakpoints (mobile/tablet/laptop/desktop)
including a full mobile rebuild of favorites, call UI, and the settings
home/sub-list split.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 20:16:33 +08:00

44 lines
1.7 KiB
TypeScript

import { useEffect, useRef } from 'react';
import { Icon } from '@/app/Icon';
import { TOAST_DURATION } from '@/lib/config';
interface ToastProps {
message: string;
variant?: 'success' | 'error';
onDone: () => void;
}
export function Toast({ message, variant = 'success', onDone }: ToastProps) {
// Call sites pass an inline `onDone` arrow, so a plain `[message, onDone]` dependency array
// restarts the auto-dismiss timer on every unrelated parent re-render (e.g. typing in an
// unrelated field after the toast appears) instead of only when a NEW message is shown.
const onDoneRef = useRef(onDone);
useEffect(() => {
onDoneRef.current = onDone;
});
useEffect(() => {
if (!message) return undefined;
const timer = window.setTimeout(() => onDoneRef.current(), TOAST_DURATION);
return () => window.clearTimeout(timer);
}, [message]);
if (!message) return null;
return (
<div
role="status"
// `position:fixed` resolves against the viewport, not AppShell's own Outlet box -- below 640px
// that viewport bottom is where the persistent BottomTabBar (82px tall) already sits, so the
// unconditional `bottom-12` this used to be sat squarely on top of it on every phone-width
// screen, for every Toast call site in the app. `sm:bottom-12` restores the original 48px gap
// once the tab bar is gone (>=640px, NavRail shown instead).
className="fixed bottom-[130px] left-1/2 z-50 flex -translate-x-1/2 items-center gap-2 rounded-lg bg-text-heading/94 px-4 py-2.5 text-sm text-white sm:bottom-12"
>
<Icon name={variant === 'error' ? 'error' : 'check_circle'} className={`text-[18px] ${variant === 'error' ? 'text-danger-text' : 'text-online'}`} />
{message}
</div>
);
}