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.
		
		
		
		
		
			
		
			
				
	
	
		
			35 lines
		
	
	
		
			953 B
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			35 lines
		
	
	
		
			953 B
		
	
	
	
		
			TypeScript
		
	
| import React from 'react';
 | |
| import { useSelector } from 'react-redux';
 | |
| import { MessageRenderingProps } from '../../../models/messageType';
 | |
| import { getMessageStatusProps } from '../../../state/selectors/conversations';
 | |
| import { OutgoingMessageStatus } from './OutgoingMessageStatus';
 | |
| 
 | |
| type Props = {
 | |
|   isCorrectSide: boolean;
 | |
|   messageId: string;
 | |
| };
 | |
| 
 | |
| export type MessageStatusSelectorProps = Pick<MessageRenderingProps, 'direction' | 'status'>;
 | |
| 
 | |
| export const MessageStatus = (props: Props) => {
 | |
|   const { isCorrectSide } = props;
 | |
| 
 | |
|   const selected = useSelector(state => getMessageStatusProps(state as any, props.messageId));
 | |
|   if (!selected) {
 | |
|     return null;
 | |
|   }
 | |
|   const { status, direction } = selected;
 | |
| 
 | |
|   if (!isCorrectSide) {
 | |
|     return null;
 | |
|   }
 | |
|   const isIncoming = direction === 'incoming';
 | |
| 
 | |
|   const showStatus = !isIncoming && Boolean(status);
 | |
|   if (!showStatus) {
 | |
|     return null;
 | |
|   }
 | |
| 
 | |
|   return <OutgoingMessageStatus status={status} />;
 | |
| };
 |