import React, { useEffect, useState } from 'react'; import Button from '@custom/shared/components/Button'; import { TrayButton } from '@custom/shared/components/Tray'; import { ReactComponent as IconStar } from '@custom/shared/icons/star-md.svg'; const COOLDOWN = 1500; export const Tray = () => { const [showEmojis, setShowEmojis] = useState(false); const [isThrottled, setIsThrottled] = useState(false); function sendEmoji(emoji) { // Dispatch custom event here so the local user can see their own emoji window.dispatchEvent( new CustomEvent('reaction_added', { detail: { emoji } }) ); setShowEmojis(false); setIsThrottled(true); } // Pseudo-throttling (should ideally be done serverside) useEffect(() => { if (!isThrottled) { return false; } const t = setTimeout(() => setIsThrottled(false), COOLDOWN); return () => clearTimeout(t); }, [isThrottled]); return (