Add more logging for reactions handling

This commit is contained in:
Ken Powers
2020-02-07 18:12:47 -05:00
committed by GitHub
parent fba401aee8
commit f37e73c723

View File

@@ -2222,8 +2222,11 @@
async handleReaction(reaction) { async handleReaction(reaction) {
const reactions = this.get('reactions') || []; const reactions = this.get('reactions') || [];
const messageId = this.idForLogging();
const count = reactions.length;
if (reaction.get('remove')) { if (reaction.get('remove')) {
window.log.info('Removing reaction for message', messageId);
const newReactions = reactions.filter( const newReactions = reactions.filter(
re => re =>
re.emoji !== reaction.get('emoji') || re.emoji !== reaction.get('emoji') ||
@@ -2231,6 +2234,7 @@
); );
this.set({ reactions: newReactions }); this.set({ reactions: newReactions });
} else { } else {
window.log.info('Adding reaction for message', messageId);
const newReactions = reactions.filter( const newReactions = reactions.filter(
re => re.fromId !== reaction.get('fromId') re => re.fromId !== reaction.get('fromId')
); );
@@ -2247,6 +2251,11 @@
} }
} }
const newCount = this.get('reactions').length;
window.log.info(
`Done processing reaction for message ${messageId}. Went from ${count} to ${newCount} reactions.`
);
await window.Signal.Data.saveMessage(this.attributes, { await window.Signal.Data.saveMessage(this.attributes, {
Message: Whisper.Message, Message: Whisper.Message,
}); });