mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 00:07:56 +01:00
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:
@@ -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 {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user