diff --git a/src/script/components/MessagesList/Message/MessageWrapper.tsx b/src/script/components/MessagesList/Message/MessageWrapper.tsx index f1db94238de..242ef97a953 100644 --- a/src/script/components/MessagesList/Message/MessageWrapper.tsx +++ b/src/script/components/MessagesList/Message/MessageWrapper.tsx @@ -42,7 +42,6 @@ import {LegalHoldMessage} from './LegalHoldMessage'; import {MemberMessage} from './MemberMessage'; import {MissedMessage} from './MissedMessage'; import {PingMessage} from './PingMessage'; -import {ProtocolUpdateMessage} from './ProtocolUpdateMessage'; import {SystemMessage} from './SystemMessage'; import {VerificationMessage} from './VerificationMessage'; @@ -270,9 +269,7 @@ export const MessageWrapper: React.FC; } - if (message.isProtocolUpdate()) { - return ; - } + if (message.isMissed()) { return ; } diff --git a/src/script/components/MessagesList/Message/ProtocolUpdateMessage.tsx b/src/script/components/MessagesList/Message/ProtocolUpdateMessage.tsx deleted file mode 100644 index 2d9e52d91e8..00000000000 --- a/src/script/components/MessagesList/Message/ProtocolUpdateMessage.tsx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 {Icon} from 'Components/Icon'; -import {ProtocolUpdateMessage as ProtocolUpdateMessageEntity} from 'src/script/entity/message/ProtocolUpdateMessage'; -import {useKoSubscribableChildren} from 'Util/ComponentUtil'; - -import {MessageTime} from './MessageTime'; - -export interface ProtocolUpdateMessageProps { - message: ProtocolUpdateMessageEntity; -} - -export const ProtocolUpdateMessage: React.FC = ({message}) => { - const {caption, timestamp} = useKoSubscribableChildren(message, ['caption', 'timestamp']); - - return ( -
-
- -
-
-

- - {caption} - -

-
-
- -
-
- ); -}; diff --git a/src/script/components/MessagesList/Message/SystemMessage.tsx b/src/script/components/MessagesList/Message/SystemMessage.tsx index 3d2f476f784..04b7de06492 100644 --- a/src/script/components/MessagesList/Message/SystemMessage.tsx +++ b/src/script/components/MessagesList/Message/SystemMessage.tsx @@ -41,6 +41,12 @@ const SystemMessage: React.FC = ({message}) => { // Only set for RenameMessage, MemberMessage has a different super_type const messageName = (message as RenameMessage).name; + const includeSenderNameMessages = [ + SystemMessageType.CONVERSATION_RENAME, + SystemMessageType.CONVERSATION_MESSAGE_TIMER_UPDATE, + SystemMessageType.CONVERSATION_RECEIPT_MODE_UPDATE, + ]; + return ( <>
@@ -48,10 +54,13 @@ const SystemMessage: React.FC = ({message}) => { {message.system_message_type === SystemMessageType.CONVERSATION_RENAME && } {message.system_message_type === SystemMessageType.CONVERSATION_MESSAGE_TIMER_UPDATE && } {message.system_message_type === SystemMessageType.CONVERSATION_RECEIPT_MODE_UPDATE && } + {message.system_message_type === SystemMessageType.CONVERSATION_PROTOCOL_UPDATE && }

- {unsafeSenderName} + {includeSenderNameMessages.includes(message.system_message_type) && ( + {unsafeSenderName} + )} {caption}

diff --git a/src/script/components/MessagesList/MessageList.tsx b/src/script/components/MessagesList/MessageList.tsx index 472ed7248e3..dbfcc5d85cd 100644 --- a/src/script/components/MessagesList/MessageList.tsx +++ b/src/script/components/MessagesList/MessageList.tsx @@ -101,7 +101,7 @@ const filterDuplicatedSystemMessages = (messages: MessageEntity[]) => { } if (currentMessage.isSystem()) { - const systemMessagesToFilter = [CONVERSATION_EVENT.RENAME] as string[]; + const systemMessagesToFilter = [CONVERSATION_EVENT.RENAME, CONVERSATION_EVENT.PROTOCOL_UPDATE] as string[]; if (systemMessagesToFilter.includes(currentMessage.type)) { const uniqUpdateMessages = uniqMessages.filter( (message): message is SystemMessage => message.isSystem() && systemMessagesToFilter.includes(message.type), diff --git a/src/script/entity/message/Message.ts b/src/script/entity/message/Message.ts index 41d4f7e8293..77aba96d19d 100644 --- a/src/script/entity/message/Message.ts +++ b/src/script/entity/message/Message.ts @@ -40,7 +40,6 @@ import type {LinkPreview} from './LinkPreview'; import type {MemberMessage} from './MemberMessage'; import {MissedMessage} from './MissedMessage'; import type {PingMessage} from './PingMessage'; -import {ProtocolUpdateMessage} from './ProtocolUpdateMessage'; import type {SystemMessage} from './SystemMessage'; import type {VerificationMessage} from './VerificationMessage'; @@ -317,10 +316,6 @@ export class Message { return this.super_type === SuperType.MISSED; } - isProtocolUpdate(): this is ProtocolUpdateMessage { - return this.super_type === SuperType.PROTOCOL_UPDATE; - } - isCallTimeout(): this is CallingTimeoutMessage { return this.super_type === SuperType.CALL_TIME_OUT; } diff --git a/src/script/entity/message/ProtocolUpdateMessage.ts b/src/script/entity/message/ProtocolUpdateMessage.ts index 900cbacc6a7..b4ec861b90f 100644 --- a/src/script/entity/message/ProtocolUpdateMessage.ts +++ b/src/script/entity/message/ProtocolUpdateMessage.ts @@ -18,10 +18,9 @@ */ import {ConversationProtocol} from '@wireapp/api-client/lib/conversation'; -import {CONVERSATION_EVENT} from '@wireapp/api-client/lib/event/'; import ko from 'knockout'; -import {SuperType} from 'src/script/message/SuperType'; +import {SystemMessageType} from 'src/script/message/SystemMessageType'; import {t} from 'Util/LocalizerUtil'; import {SystemMessage} from './SystemMessage'; @@ -29,8 +28,7 @@ import {SystemMessage} from './SystemMessage'; export class ProtocolUpdateMessage extends SystemMessage { constructor(public protocol: ConversationProtocol.MIXED | ConversationProtocol.MLS) { super(); - this.type = CONVERSATION_EVENT.PROTOCOL_UPDATE; - this.super_type = SuperType.PROTOCOL_UPDATE; + this.system_message_type = SystemMessageType.CONVERSATION_PROTOCOL_UPDATE; this.caption = ko.pureComputed(() => this.protocol === ConversationProtocol.MIXED ? t('conversationProtocolUpdatedToMixed') diff --git a/src/script/message/SuperType.ts b/src/script/message/SuperType.ts index 3970b4ea82a..fe1f11584b0 100644 --- a/src/script/message/SuperType.ts +++ b/src/script/message/SuperType.ts @@ -30,7 +30,6 @@ export enum SuperType { LOCATION = 'location', MEMBER = 'member', MISSED = 'missed', - PROTOCOL_UPDATE = 'protocol-update', PING = 'ping', REACTION = 'reaction', SPECIAL = 'special', diff --git a/src/script/message/SystemMessageType.ts b/src/script/message/SystemMessageType.ts index adea6201ce9..d436aa55baa 100644 --- a/src/script/message/SystemMessageType.ts +++ b/src/script/message/SystemMessageType.ts @@ -29,6 +29,7 @@ export enum SystemMessageType { CONVERSATION_MESSAGE_TIMER_UPDATE = 'message-timer-update', CONVERSATION_RECEIPT_MODE_UPDATE = 'receipt-mode-update', CONVERSATION_RENAME = 'rename', + CONVERSATION_PROTOCOL_UPDATE = 'protocol-update', CONVERSATION_RESUME = 'resume', MEMBER_JOIN = 'join', MEMBER_LEAVE = 'leave',