Apply reactions optimistically

This commit is contained in:
Fedor Indutny 2021-05-13 12:10:20 -07:00 committed by Scott Nonnenberg
parent 18abe93022
commit 03eaa9eb3e
6 changed files with 54 additions and 33 deletions

View file

@ -61,11 +61,11 @@
reaction.get('targetAuthorUuid'),
reaction.get('targetTimestamp')
);
return;
return undefined;
}
// awaiting is safe since `onReaction` is never called from inside the queue
await targetConversation.queueJob(async () => {
return await targetConversation.queueJob(async () => {
window.log.info(
'Handling reaction for',
reaction.get('targetTimestamp')
@ -112,7 +112,7 @@
oldReaction.forEach(r => this.remove(r));
}
return;
return undefined;
}
const message = MessageController.register(
@ -120,15 +120,18 @@
targetMessage
);
await message.handleReaction(reaction);
const oldReaction = await message.handleReaction(reaction);
this.remove(reaction);
return oldReaction;
});
} catch (error) {
window.log.error(
'Reactions.onReaction error:',
error && error.stack ? error.stack : error
);
return undefined;
}
},
}))();