import React from 'react'; import { FormattedMessage } from 'react-intl'; import Avatar from 'soapbox/components/avatar'; import DisplayName from 'soapbox/components/display-name'; import Icon from 'soapbox/components/icon'; import { Counter } from 'soapbox/components/ui'; import emojify from 'soapbox/features/emoji/emoji'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetChat } from 'soapbox/selectors'; import type { Account as AccountEntity, Chat as ChatEntity } from 'soapbox/types/entities'; const getChat = makeGetChat(); interface IChat { chatId: string, onClick: (chat: any) => void, } const Chat: React.FC = ({ chatId, onClick }) => { const chat = useAppSelector((state) => { const chat = state.chats.items.get(chatId); return chat ? getChat(state, (chat as any).toJS()) : undefined; }) as ChatEntity; const account = chat.account as AccountEntity; if (!chat || !account) return null; const unreadCount = chat.unread; const content = chat.getIn(['last_message', 'content']); const attachment = chat.getIn(['last_message', 'attachment']); const image = attachment && (attachment as any).getIn(['pleroma', 'mime_type'], '').startsWith('image/'); const parsedContent = content ? emojify(content) : ''; return (
); }; export default Chat;