Handle multiple out of order reactions
This commit is contained in:
parent
37ad95af27
commit
42152be4af
2 changed files with 20 additions and 16 deletions
|
@ -2401,11 +2401,11 @@
|
||||||
await conversation.notify(message);
|
await conversation.notify(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does this message have a pending, previously-received associated reaction?
|
// Does this message have any pending, previously-received associated reactions?
|
||||||
const reaction = Whisper.Reactions.forMessage(message);
|
const reactions = Whisper.Reactions.forMessage(message);
|
||||||
if (reaction) {
|
reactions.forEach(reaction => {
|
||||||
message.handleReaction(reaction);
|
message.handleReaction(reaction);
|
||||||
}
|
});
|
||||||
|
|
||||||
Whisper.events.trigger('incrementProgress');
|
Whisper.events.trigger('incrementProgress');
|
||||||
confirm();
|
confirm();
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/* global
|
/* global
|
||||||
Backbone,
|
Backbone,
|
||||||
Whisper,
|
Whisper,
|
||||||
MessageController
|
MessageController,
|
||||||
|
ConversationController
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* eslint-disable more/no-then */
|
/* eslint-disable more/no-then */
|
||||||
|
@ -14,29 +15,32 @@
|
||||||
Whisper.Reactions = new (Backbone.Collection.extend({
|
Whisper.Reactions = new (Backbone.Collection.extend({
|
||||||
forMessage(message) {
|
forMessage(message) {
|
||||||
if (message.isOutgoing()) {
|
if (message.isOutgoing()) {
|
||||||
const outgoingReaction = this.findWhere({
|
const outgoingReactions = this.filter({
|
||||||
targetTimestamp: message.get('sent_at'),
|
targetTimestamp: message.get('sent_at'),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (outgoingReaction) {
|
if (outgoingReactions.length > 0) {
|
||||||
window.log.info('Found early reaction for outgoing message');
|
window.log.info('Found early reaction for outgoing message');
|
||||||
this.remove(outgoingReaction);
|
this.remove(outgoingReactions);
|
||||||
return outgoingReaction;
|
return outgoingReactions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const reactionBySource = this.findWhere({
|
const reactionsBySource = this.filter(re => {
|
||||||
targetAuthorE164: message.get('source'),
|
const mcid = message.get('conversationId');
|
||||||
targetTimestamp: message.get('sent_at'),
|
const recid = ConversationController.getConversationId(
|
||||||
|
re.get('targetAuthorE164') || re.get('targetAuthorUuid')
|
||||||
|
);
|
||||||
|
return mcid === recid;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (reactionBySource) {
|
if (reactionsBySource.length > 0) {
|
||||||
window.log.info('Found early reaction for message');
|
window.log.info('Found early reaction for message');
|
||||||
this.remove(reactionBySource);
|
this.remove(reactionsBySource);
|
||||||
return reactionBySource;
|
return reactionsBySource;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return [];
|
||||||
},
|
},
|
||||||
async onReaction(reaction) {
|
async onReaction(reaction) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue