|
|
|
@ -3,10 +3,11 @@ import { isEmpty } from 'lodash';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
import {
|
|
|
|
|
useConversationPropsById,
|
|
|
|
|
useConversationInteractionPropsById,
|
|
|
|
|
useHasUnread,
|
|
|
|
|
useIsPrivate,
|
|
|
|
|
useIsTyping,
|
|
|
|
|
useLastMessage,
|
|
|
|
|
} from '../../../hooks/useParamSelector';
|
|
|
|
|
import { isSearching } from '../../../state/selectors/search';
|
|
|
|
|
import { getIsMessageRequestOverlayShown } from '../../../state/selectors/section';
|
|
|
|
@ -14,18 +15,11 @@ import { TypingAnimation } from '../../conversation/TypingAnimation';
|
|
|
|
|
import { MessageBody } from '../../conversation/message/message-content/MessageBody';
|
|
|
|
|
import { OutgoingMessageStatus } from '../../conversation/message/message-content/OutgoingMessageStatus';
|
|
|
|
|
import { useConvoIdFromContext } from './ConvoIdContext';
|
|
|
|
|
|
|
|
|
|
function useLastMessageFromConvo(convoId: string) {
|
|
|
|
|
const convoProps = useConversationPropsById(convoId);
|
|
|
|
|
if (!convoProps) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return convoProps.lastMessage;
|
|
|
|
|
}
|
|
|
|
|
import { InteractionItem } from './InteractionItem';
|
|
|
|
|
|
|
|
|
|
export const MessageItem = () => {
|
|
|
|
|
const conversationId = useConvoIdFromContext();
|
|
|
|
|
const lastMessage = useLastMessageFromConvo(conversationId);
|
|
|
|
|
const lastMessage = useLastMessage(conversationId);
|
|
|
|
|
const isGroup = !useIsPrivate(conversationId);
|
|
|
|
|
|
|
|
|
|
const hasUnread = useHasUnread(conversationId);
|
|
|
|
@ -34,6 +28,12 @@ export const MessageItem = () => {
|
|
|
|
|
|
|
|
|
|
const isSearchingMode = useSelector(isSearching);
|
|
|
|
|
|
|
|
|
|
const interactionProps = useConversationInteractionPropsById(conversationId);
|
|
|
|
|
|
|
|
|
|
if (!isConvoTyping && interactionProps) {
|
|
|
|
|
return <InteractionItem {...interactionProps} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!lastMessage && !isConvoTyping) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|