Make block/report keep chat timestamp

This commit is contained in:
Jamie Kyle 2024-04-02 09:41:28 -07:00 committed by GitHub
parent 89ebbf8af4
commit 85414e1c95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 43 additions and 5 deletions

View file

@ -2654,6 +2654,10 @@
"messageformat": "Message Request", "messageformat": "Message Request",
"description": "Preview shown for conversation if the user has not yet accepted an incoming 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": { "icu:ConversationListItem--draft-prefix": {
"messageformat": "Draft:", "messageformat": "Draft:",
"description": "Prefix shown in italic in conversation view when a draft is saved" "description": "Prefix shown in italic in conversation view when a draft is saved"

View file

@ -4948,6 +4948,22 @@ button.module-image__border-overlay:focus {
height: 36px; // two lines 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 { &__message-request {
@include font-body-2-bold; @include font-body-2-bold;

View file

@ -377,6 +377,7 @@ export function ConversationList({
'draftPreview', 'draftPreview',
'groupId', 'groupId',
'id', 'id',
'isBlocked',
'isMe', 'isMe',
'isSelected', 'isSelected',
'isPinned', 'isPinned',

View file

@ -45,6 +45,7 @@ export type PropsData = Pick<
| 'draftPreview' | 'draftPreview'
| 'groupId' | 'groupId'
| 'id' | 'id'
| 'isBlocked'
| 'isMe' | 'isMe'
// NOTE: Passed for CI, not used for rendering // NOTE: Passed for CI, not used for rendering
| 'isPinned' | 'isPinned'
@ -89,6 +90,7 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
groupId, groupId,
i18n, i18n,
id, id,
isBlocked,
isMe, isMe,
isSelected, isSelected,
lastMessage, lastMessage,
@ -135,7 +137,13 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
let messageText: ReactNode = null; let messageText: ReactNode = null;
let messageStatusIcon: ReactNode = null; let messageStatusIcon: ReactNode = null;
if (!acceptedMessageRequest && removalStage !== 'justNotification') { if (isBlocked) {
messageText = (
<span className={`${MESSAGE_TEXT_CLASS_NAME}__blocked`}>
{i18n('icu:ConversationListItem--blocked')}
</span>
);
} else if (!acceptedMessageRequest && removalStage !== 'justNotification') {
messageText = ( messageText = (
<span className={`${MESSAGE_TEXT_CLASS_NAME}__message-request`}> <span className={`${MESSAGE_TEXT_CLASS_NAME}__message-request`}>
{i18n('icu:ConversationListItem--message-request')} {i18n('icu:ConversationListItem--message-request')}

View file

@ -2122,17 +2122,26 @@ export class ConversationModel extends window.Backbone
async addMessageRequestResponseEventMessage( async addMessageRequestResponseEventMessage(
event: MessageRequestResponseEvent event: MessageRequestResponseEvent
): Promise<void> { ): Promise<void> {
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 = { const message: MessageAttributesType = {
id: generateGuid(), id: generateGuid(),
conversationId: this.id, conversationId: this.id,
type: 'message-request-response-event', type: 'message-request-response-event',
sent_at: now, sent_at: maybeLastMessageTimestamp,
received_at: incrementMessageCounter(), received_at: incrementMessageCounter(),
received_at_ms: now, received_at_ms: maybeLastMessageTimestamp,
readStatus: ReadStatus.Read, readStatus: ReadStatus.Read,
seenStatus: SeenStatus.NotApplicable, seenStatus: SeenStatus.NotApplicable,
timestamp: now, timestamp,
messageRequestResponseEvent: event, messageRequestResponseEvent: event,
}; };