diff --git a/client/app/dashboard/page.tsx b/client/app/dashboard/page.tsx index 5c8a3d2..4a8c716 100644 --- a/client/app/dashboard/page.tsx +++ b/client/app/dashboard/page.tsx @@ -45,6 +45,10 @@ export default function DashboardPage() { const { selection, status: overlayStatus } = useOverlaySelection(); const { connected, liveId, connect, disconnect, connecting } = useConnection(); const [confirmUrl, setConfirmUrl] = useState(null); + const [superChatPulse, setSuperChatPulse] = useState(false); + const [memberPulse, setMemberPulse] = useState(false); + const prevSuperChatCountRef = useRef(0); + const prevMemberCountRef = useRef(0); const handleSelect = useCallback( async (message: ChatMessage) => { @@ -109,6 +113,38 @@ export default function DashboardPage() { const newMembers = useMemo(() => messages.filter(m => m.membershipGift || m.membershipGiftPurchase), [messages]); const regularMessages = useMemo(() => messages.filter(m => !m.superChat && !m.membershipGift && !m.membershipGiftPurchase), [messages]); + // Detect new superchats and trigger pulse + useEffect(() => { + const prevCount = prevSuperChatCountRef.current; + const currentCount = superChats.length; + + // Trigger pulse if count increased (but not on initial mount when both are 0) + if (currentCount > prevCount && !(prevCount === 0 && currentCount === 0)) { + setSuperChatPulse(true); + const timer = setTimeout(() => setSuperChatPulse(false), 10000); + prevSuperChatCountRef.current = currentCount; + return () => clearTimeout(timer); + } + + prevSuperChatCountRef.current = currentCount; + }, [superChats.length]); + + // Detect new members and trigger pulse + useEffect(() => { + const prevCount = prevMemberCountRef.current; + const currentCount = newMembers.length; + + // Trigger pulse if count increased (but not on initial mount when both are 0) + if (currentCount > prevCount && !(prevCount === 0 && currentCount === 0)) { + setMemberPulse(true); + const timer = setTimeout(() => setMemberPulse(false), 10000); + prevMemberCountRef.current = currentCount; + return () => clearTimeout(timer); + } + + prevMemberCountRef.current = currentCount; + }, [newMembers.length]); + return (
{!connected && ( @@ -144,10 +180,10 @@ export default function DashboardPage() {
Messages {regularMessages.length}
-
+
Superchats {superChats.length}
-
+
Members {newMembers.length}