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

35 lines
957 B
TypeScript

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