import React, { useRef } from 'react'; import { Avatar, HStack, Icon, Stack, Text } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification_badge'; import { useChatContext } from 'soapbox/contexts/chat-context'; import ChatBox from './chat-box'; import ChatPaneHeader from './chat-pane-header'; import ChatSettings from './chat-settings'; /** Floating desktop chat window. */ const ChatWindow = () => { const { chat, setChat, isOpen, isEditing, needsAcceptance, setEditing, toggleChatPane } = useChatContext(); const inputRef = useRef(); const closeChat = () => setChat(null); const openAndFocusChat = () => { toggleChatPane(); inputRef.current?.focus(); }; const openChatSettings = () => setEditing(true); const secondaryAction = () => { if (needsAcceptance) { return undefined; } return isOpen ? openChatSettings : openAndFocusChat; }; if (!chat) return null; if (isEditing) { return ; } return ( <> {isOpen && ( )} {isOpen && ( )}
{chat.account.display_name} {chat.account.verified && }
@{chat.account.acct}
} secondaryAction={secondaryAction()} secondaryActionIcon={isOpen ? require('@tabler/icons/info-circle.svg') : require('@tabler/icons/edit.svg')} isToggleable={!isOpen} isOpen={isOpen} onToggle={toggleChatPane} /> null} /> ); }; export default ChatWindow;