Update UI for own admin delete on incoming message

Co-authored-by: Jamie <113370520+jamiebuilds-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-04 16:37:48 -06:00
committed by GitHub
parent 9d07198b15
commit a245f03da7
4 changed files with 56 additions and 37 deletions

View File

@@ -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<Props, State> {
if (deletedForEveryone) {
let text: React.JSX.Element | string;
if (deletedForEveryoneByAdmin != null) {
text = (
<I18n
id="icu:message--deletedByAdmin"
i18n={i18n}
components={{
admin: (
<strong>
<ContactName
title={deletedForEveryoneByAdmin.title}
contactNameColor={
deletedForEveryoneByAdmin.contactNameColor
}
onClick={() => {
showContactModal({
conversationId,
contactId: deletedForEveryoneByAdmin.conversationId,
});
}}
/>
</strong>
),
}}
/>
);
if (deletedForEveryoneByAdmin.isMe) {
text = i18n('icu:message--deletedForEveryone--outgoing');
} else {
text = (
<I18n
id="icu:message--deletedByAdmin"
i18n={i18n}
components={{
admin: (
<strong>
<ContactName
title={deletedForEveryoneByAdmin.title}
contactNameColor={
deletedForEveryoneByAdmin.contactNameColor
}
onClick={() => {
showContactModal({
conversationId,
contactId: deletedForEveryoneByAdmin.conversationId,
});
}}
/>
</strong>
),
}}
/>
);
}
} else if (direction === 'outgoing') {
text = i18n('icu:message--deletedForEveryone--outgoing');
} else {

View File

@@ -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({

View File

@@ -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,
};
}

View File

@@ -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,
};
}