import React, { useEffect } from 'react' import PropTypes from 'prop-types' import MessageList from './message-list' import MessageInput from './message-input' import InfiniteScroll from './infinite-scroll' import Icon from '../../../shared/components/icon' import { useTranslation } from 'react-i18next' import { useChatStore } from '../store/chat-store-effect' import withErrorBoundary from '../../../infrastructure/error-boundary' function ChatPane({ resetUnreadMessages }) { const { t } = useTranslation() const { atEnd, loading, loadMoreMessages, messages, sendMessage, userId } = useChatStore() useEffect(() => { loadMoreMessages() // eslint-disable-next-line react-hooks/exhaustive-deps }, []) const shouldDisplayPlaceholder = !loading && messages.length === 0 const messageContentCount = messages.reduce( (acc, { contents }) => acc + contents.length, 0 ) return ( ) } function LoadingSpinner() { const { t } = useTranslation() return (
{` ${t('loading')}…`}
) } function Placeholder() { const { t } = useTranslation() return ( <>
{t('no_messages')}
{t('send_first_message')}
) } ChatPane.propTypes = { resetUnreadMessages: PropTypes.func.isRequired } export default withErrorBoundary(ChatPane)