From 5be7feeebd7b83d9ff79360e0e5f07f52fdf94d0 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:19:39 -0500 Subject: [PATCH] Make block/report keep chat timestamp Co-authored-by: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> --- _locales/en/messages.json | 4 ++++ stylesheets/_modules.scss | 16 ++++++++++++++++ ts/components/ConversationList.tsx | 1 + .../conversationList/ConversationListItem.tsx | 10 +++++++++- ts/models/conversations.ts | 17 +++++++++++++---- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 9210713dfc..13c862b792 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2654,6 +2654,10 @@ "messageformat": "Message Request", "description": "Preview shown for conversation if the user has not yet accepted an incoming message request" }, + "icu:ConversationListItem--blocked": { + "messageformat": "Blocked", + "description": "Preview shown for conversation that has been blocked" + }, "icu:ConversationListItem--draft-prefix": { "messageformat": "Draft:", "description": "Prefix shown in italic in conversation view when a draft is saved" diff --git a/stylesheets/_modules.scss b/stylesheets/_modules.scss index cd977264e1..ddfce4fe87 100644 --- a/stylesheets/_modules.scss +++ b/stylesheets/_modules.scss @@ -4948,6 +4948,22 @@ button.module-image__border-overlay:focus { height: 36px; // two lines } + &__blocked { + display: flex; + align-items: center; + &::before { + content: ''; + display: inline-block; + width: 16px; + height: 16px; + margin-inline-end: 4px; + @include color-svg( + '../images/icons/v3/block/block.svg', + currentColor + ); + } + } + &__message-request { @include font-body-2-bold; diff --git a/ts/components/ConversationList.tsx b/ts/components/ConversationList.tsx index aa99b73b96..c14d12a18d 100644 --- a/ts/components/ConversationList.tsx +++ b/ts/components/ConversationList.tsx @@ -377,6 +377,7 @@ export function ConversationList({ 'draftPreview', 'groupId', 'id', + 'isBlocked', 'isMe', 'isSelected', 'isPinned', diff --git a/ts/components/conversationList/ConversationListItem.tsx b/ts/components/conversationList/ConversationListItem.tsx index 4bfbf2194f..10755d1f5a 100644 --- a/ts/components/conversationList/ConversationListItem.tsx +++ b/ts/components/conversationList/ConversationListItem.tsx @@ -45,6 +45,7 @@ export type PropsData = Pick< | 'draftPreview' | 'groupId' | 'id' + | 'isBlocked' | 'isMe' // NOTE: Passed for CI, not used for rendering | 'isPinned' @@ -89,6 +90,7 @@ export const ConversationListItem: FunctionComponent = React.memo( groupId, i18n, id, + isBlocked, isMe, isSelected, lastMessage, @@ -135,7 +137,13 @@ export const ConversationListItem: FunctionComponent = React.memo( let messageText: ReactNode = null; let messageStatusIcon: ReactNode = null; - if (!acceptedMessageRequest && removalStage !== 'justNotification') { + if (isBlocked) { + messageText = ( + + {i18n('icu:ConversationListItem--blocked')} + + ); + } else if (!acceptedMessageRequest && removalStage !== 'justNotification') { messageText = ( {i18n('icu:ConversationListItem--message-request')} diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 1bf664148f..2ac8ba246e 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -2122,17 +2122,26 @@ export class ConversationModel extends window.Backbone async addMessageRequestResponseEventMessage( event: MessageRequestResponseEvent ): Promise { - const now = Date.now(); + const timestamp = Date.now(); + const lastMessageTimestamp = + // Fallback to `timestamp` since `lastMessageReceivedAtMs` is new + this.get('lastMessageReceivedAtMs') ?? this.get('timestamp') ?? timestamp; + + const maybeLastMessageTimestamp = + event === MessageRequestResponseEvent.ACCEPT + ? timestamp + : lastMessageTimestamp; + const message: MessageAttributesType = { id: generateGuid(), conversationId: this.id, type: 'message-request-response-event', - sent_at: now, + sent_at: maybeLastMessageTimestamp, received_at: incrementMessageCounter(), - received_at_ms: now, + received_at_ms: maybeLastMessageTimestamp, readStatus: ReadStatus.Read, seenStatus: SeenStatus.NotApplicable, - timestamp: now, + timestamp, messageRequestResponseEvent: event, };