diff --git a/ts/components/conversation/Message.dom.tsx b/ts/components/conversation/Message.dom.tsx index 853645eb07..f3b18a9795 100644 --- a/ts/components/conversation/Message.dom.tsx +++ b/ts/components/conversation/Message.dom.tsx @@ -345,6 +345,7 @@ export type PropsData = { conversationId: string; title: string; contactNameColor: ContactNameColorType; + isMe: boolean; }; attachmentDroppedDueToSize?: boolean; @@ -2376,30 +2377,34 @@ export class Message extends React.PureComponent { if (deletedForEveryone) { let text: React.JSX.Element | string; if (deletedForEveryoneByAdmin != null) { - text = ( - - { - showContactModal({ - conversationId, - contactId: deletedForEveryoneByAdmin.conversationId, - }); - }} - /> - - ), - }} - /> - ); + if (deletedForEveryoneByAdmin.isMe) { + text = i18n('icu:message--deletedForEveryone--outgoing'); + } else { + text = ( + + { + showContactModal({ + conversationId, + contactId: deletedForEveryoneByAdmin.conversationId, + }); + }} + /> + + ), + }} + /> + ); + } } else if (direction === 'outgoing') { text = i18n('icu:message--deletedForEveryone--outgoing'); } else { diff --git a/ts/components/conversation/TimelineMessage.dom.stories.tsx b/ts/components/conversation/TimelineMessage.dom.stories.tsx index c0d67b6338..4bdffe6a92 100644 --- a/ts/components/conversation/TimelineMessage.dom.stories.tsx +++ b/ts/components/conversation/TimelineMessage.dom.stories.tsx @@ -952,6 +952,7 @@ export function DeletedByAdmin(): React.JSX.Element { conversationId: 'admin-conversation-id', title: 'Alice Smith', contactNameColor: '200', + isMe: false, }, canForward: false, status: 'sent', @@ -995,6 +996,7 @@ export function AdminDeletedPending(): React.JSX.Element { conversationId: 'admin-conversation-id', title: 'Alice Smith', contactNameColor: '200', + isMe: false, }, status: 'sending', direction: 'outgoing', @@ -1008,6 +1010,7 @@ export function AdminDeletedPending(): React.JSX.Element { conversationId: 'admin-conversation-id', title: 'Alice Smith', contactNameColor: '200', + isMe: false, }, status: 'sending', direction: 'incoming', @@ -1081,6 +1084,7 @@ export function AdminDeletedWithError(): React.JSX.Element { conversationId: 'admin-conversation-id', title: 'Alice Smith', contactNameColor: '200' as const, + isMe: false, }, }; const propsOutgoingPartialError = createProps({ @@ -1136,6 +1140,7 @@ export function AdminDeletedWithErrorCanRetry(): React.JSX.Element { conversationId: 'admin-conversation-id', title: 'Alice Smith', contactNameColor: '200' as const, + isMe: false, }, }; const propsOutgoingPartialError = createProps({ diff --git a/ts/state/selectors/message.preload.ts b/ts/state/selectors/message.preload.ts index 6fefae52ec..d594cf6498 100644 --- a/ts/state/selectors/message.preload.ts +++ b/ts/state/selectors/message.preload.ts @@ -2117,26 +2117,30 @@ function getDeletedForEveryoneByAdmin( } ): PropsData['deletedForEveryoneByAdmin'] { const { deletedForEveryoneByAdminAci } = message; + const { conversationSelector } = options; if (deletedForEveryoneByAdminAci == null) { - return undefined; + return; } // If the admin deleted their own message, display it like a normal delete const messageAuthorAci = getSourceServiceId(message, options.ourAci); if (deletedForEveryoneByAdminAci === messageAuthorAci) { - return undefined; + return; } - const adminConversationId = - window.ConversationController.getConversationId( - deletedForEveryoneByAdminAci - ) ?? ''; - const adminConversation = options.conversationSelector(adminConversationId); + const adminConversationId = window.ConversationController.getConversationId( + deletedForEveryoneByAdminAci + ); + if (adminConversationId == null) { + return; + } + const adminConversation = conversationSelector(adminConversationId); return { conversationId: adminConversationId, - title: adminConversation?.title ?? '', + title: adminConversation.title, contactNameColor: getContactNameColor( options.contactNameColors, adminConversationId ), + isMe: adminConversation.isMe, }; } diff --git a/ts/util/getLastMessage.preload.ts b/ts/util/getLastMessage.preload.ts index 5d65a48521..0956215c7f 100644 --- a/ts/util/getLastMessage.preload.ts +++ b/ts/util/getLastMessage.preload.ts @@ -44,13 +44,18 @@ export function getLastMessage( const { lastMessageAuthorAci, lastMessageDeletedForEveryoneByAdminAci } = conversationAttrs; - // Only show admin name when the admin deleted someone else's message + // Don't show admin name when the admin deleted their own message or when + // the current user is the admin (show "You deleted this message" instead) const isAdminDeletingOwnMessage = lastMessageDeletedForEveryoneByAdminAci != null && lastMessageDeletedForEveryoneByAdminAci === lastMessageAuthorAci; - const deletedByAdminName = isAdminDeletingOwnMessage - ? null - : getNameForAci(lastMessageDeletedForEveryoneByAdminAci); + const isAdminMe = + lastMessageDeletedForEveryoneByAdminAci != null && + lastMessageDeletedForEveryoneByAdminAci === ourAci; + const deletedByAdminName = + isAdminDeletingOwnMessage || isAdminMe + ? null + : getNameForAci(lastMessageDeletedForEveryoneByAdminAci); const authorName = getDisplayNameForAci(lastMessageAuthorAci, ourAci) ?? @@ -61,7 +66,7 @@ export function getLastMessage( return { deletedForEveryone: true, deletedByAdminName, - isOutgoing: lastMessageAuthorAci === ourAci, + isOutgoing: lastMessageAuthorAci === ourAci || isAdminMe, authorName, }; }