/* * Wire * Copyright (C) 2021 Wire Swiss GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * */ import React from 'react'; import {Button, ButtonVariant} from '@wireapp/react-ui-kit'; import * as Icon from 'Components/Icon'; import {MemberMessage as MemberMessageEntity} from 'src/script/entity/message/MemberMessage'; import {User} from 'src/script/entity/User'; import {SystemMessageType} from 'src/script/message/SystemMessageType'; import {useKoSubscribableChildren} from 'Util/ComponentUtil'; import {t} from 'Util/LocalizerUtil'; import {ConnectedMessage} from './MemberMessage/ConnectedMessage'; import {MessageContent} from './MemberMessage/MessageContent'; import {MessageTime} from './MessageTime'; interface MemberMessageProps { classifiedDomains?: string[]; hasReadReceiptsTurnedOn: boolean; isSelfTemporaryGuest: boolean; message: MemberMessageEntity; onClickCancelRequest: (message: MemberMessageEntity) => void; onClickInvitePeople: () => void; onClickParticipants: (participants: User[]) => void; shouldShowInvitePeople: boolean; conversationName: string; } export const MemberMessage: React.FC = ({ message, shouldShowInvitePeople, isSelfTemporaryGuest, hasReadReceiptsTurnedOn, onClickInvitePeople, onClickParticipants, onClickCancelRequest, classifiedDomains, conversationName, }) => { const {otherUser, timestamp, user, htmlGroupCreationHeader, showNamedCreation, hasUsers} = useKoSubscribableChildren( message, ['otherUser', 'timestamp', 'user', 'htmlGroupCreationHeader', 'showNamedCreation', 'hasUsers'], ); const isGroupCreation = message.isGroupCreation(); const isMemberRemoval = message.isMemberRemoval(); const isMemberJoin = message.isMemberJoin(); const isMemberLeave = message.isMemberLeave(); const isMemberChange = message.isMemberChange(); const isConnectedMessage = [SystemMessageType.CONNECTION_ACCEPTED, SystemMessageType.CONNECTION_REQUEST].includes( message.memberMessageType, ); if (isConnectedMessage) { return ( onClickCancelRequest(message)} classifiedDomains={classifiedDomains} /> ); } return ( <> {showNamedCreation && (

{conversationName}

)} {hasUsers && (
{isGroupCreation && } {isMemberRemoval && } {isMemberJoin && }
{isMemberChange && (
)}
)} {hasUsers && message.showServicesWarning && (

{t('conversationServicesWarning')}

)} {isGroupCreation && shouldShowInvitePeople && (

{t('guestRoomConversationHead')}

)} {isGroupCreation && isSelfTemporaryGuest && (

{t('temporaryGuestJoinMessage')}

{t('temporaryGuestJoinDescription')}

)} {isGroupCreation && hasReadReceiptsTurnedOn && (

{t('conversationCreateReceiptsEnabled')}

)} {isMemberLeave && user.isMe && isSelfTemporaryGuest && (

{t('temporaryGuestLeaveDescription')}

)} {isGroupCreation && ( <>

{t('conversationNewConversation')}

{t('conversationUnverifiedUserWarning')}

)} ); };