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.
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
2 years ago
|
import React from 'react';
|
||
|
import { isEmpty } from 'lodash';
|
||
|
|
||
|
import { useIsPrivate, useIsPublic } from '../../../hooks/useParamSelector';
|
||
|
import { MessageBody } from '../../conversation/message/message-content/MessageBody';
|
||
|
import { assertUnreachable } from '../../../types/sqlSharedTypes';
|
||
|
import { ConfirmationStatus } from '../../dialog/SessionConfirm';
|
||
|
import {
|
||
|
ConversationInteractionStatus,
|
||
|
ConversationInteractionType,
|
||
|
} from '../../../interactions/conversationInteractions';
|
||
|
|
||
|
type InteractionItemProps = {
|
||
|
status: ConfirmationStatus | undefined;
|
||
|
type: ConversationInteractionType | undefined;
|
||
|
conversationId: string | undefined;
|
||
|
};
|
||
|
|
||
|
export const InteractionItem = (props: InteractionItemProps) => {
|
||
|
const { status, type, conversationId } = props;
|
||
|
const isGroup = !useIsPrivate(conversationId);
|
||
|
const isCommunity = useIsPublic(conversationId);
|
||
|
|
||
|
if (!type) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
let text = '';
|
||
|
window.log.debug(`WIP: InteractionItem updating status for ${type} ${status}`);
|
||
|
switch (type) {
|
||
|
case ConversationInteractionType.Leave:
|
||
|
const failText = isCommunity
|
||
|
? ''
|
||
|
: isGroup
|
||
|
? window.i18n('leaveGroupFailed')
|
||
|
: window.i18n('deleteConversationFailed');
|
||
|
|
||
|
text =
|
||
|
status === ConversationInteractionStatus.Error
|
||
|
? failText
|
||
|
: status === ConversationInteractionStatus.Loading
|
||
|
? window.i18n('leaving')
|
||
|
: '';
|
||
|
break;
|
||
|
default:
|
||
|
assertUnreachable(type, `MessageItem: Missing case error "${type}"`);
|
||
|
}
|
||
|
|
||
|
if (isEmpty(text)) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<div className="module-conversation-list-item__message">
|
||
|
<div className="module-conversation-list-item__message__text">
|
||
|
<MessageBody text={text} disableJumbomoji={true} disableLinks={true} isGroup={isGroup} />
|
||
|
</div>
|
||
|
</div>
|
||
|
);
|
||
|
};
|