Use correct timestamp for receipts of edited messages

This commit is contained in:
Fedor Indutny 2023-05-16 10:37:12 -07:00 committed by GitHub
parent 8fe0047822
commit 5869717cd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 156 additions and 52 deletions

View file

@ -16,6 +16,7 @@ import { getContactId, getContact } from '../messages/helpers';
import { isDirectConversation, isMe } from '../util/whatTypeOfConversation';
import { isOutgoing, isStory } from '../state/selectors/message';
import { strictAssert } from '../util/assert';
import { getMessageSentTimestampSet } from '../util/getMessageSentTimestampSet';
export class ReactionModel extends Model<ReactionAttributesType> {}
@ -31,9 +32,10 @@ export class Reactions extends Collection<ReactionModel> {
}
forMessage(message: MessageModel): Array<ReactionModel> {
const sentTimestamps = getMessageSentTimestampSet(message.attributes);
if (isOutgoing(message.attributes)) {
const outgoingReactions = this.filter(
item => item.get('targetTimestamp') === message.get('sent_at')
const outgoingReactions = this.filter(item =>
sentTimestamps.has(item.get('targetTimestamp'))
);
if (outgoingReactions.length > 0) {
@ -44,14 +46,15 @@ export class Reactions extends Collection<ReactionModel> {
}
const senderId = getContactId(message.attributes);
const sentAt = message.get('sent_at');
const reactionsBySource = this.filter(re => {
const targetSender = window.ConversationController.lookupOrCreate({
uuid: re.get('targetAuthorUuid'),
reason: 'Reactions.forMessage',
});
const targetTimestamp = re.get('targetTimestamp');
return targetSender?.id === senderId && targetTimestamp === sentAt;
return (
targetSender?.id === senderId && sentTimestamps.has(targetTimestamp)
);
});
if (reactionsBySource.length > 0) {