You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/ts/components/conversation/message/message-content/MessageStatus.tsx

36 lines
1.0 KiB
TypeScript

import React from 'react';
import { MessageRenderingProps } from '../../../../models/messageType';
import { useMessageDirection, useMessageStatus } from '../../../../state/selectors';
import { OutgoingMessageStatus } from './OutgoingMessageStatus';
type Props = {
isCorrectSide: boolean;
isDetailView: boolean;
messageId: string;
dataTestId?: string;
};
export type MessageStatusSelectorProps = Pick<MessageRenderingProps, 'direction' | 'status'>;
export const MessageStatus = (props: Props) => {
const { messageId, isCorrectSide, isDetailView, dataTestId } = props;
const direction = useMessageDirection(props.messageId);
const status = useMessageStatus(props.messageId);
if (!messageId) {
return null;
}
if (!isCorrectSide || isDetailView) {
return null;
}
const isIncoming = direction === 'incoming';
const showStatus = !isIncoming && Boolean(status);
if (!showStatus) {
return null;
}
return <OutgoingMessageStatus messageId={messageId} dataTestId={dataTestId} status={status} />;
};