feat: add reaction update to the store

This commit is contained in:
fadiinho
2022-07-25 04:23:10 -03:00
committed by Adhiraj Singh
parent d04718e27a
commit 9e096c731c

View File

@@ -6,7 +6,7 @@ import { DEFAULT_CONNECTION_CONFIG } from '../Defaults'
import type makeLegacySocket from '../LegacySocket'
import type makeMDSocket from '../Socket'
import type { BaileysEventEmitter, Chat, ConnectionState, Contact, GroupMetadata, PresenceData, WAMessage, WAMessageCursor, WAMessageKey } from '../Types'
import { toNumber, updateMessageWithReceipt } from '../Utils'
import { toNumber, updateMessageWithReaction, updateMessageWithReceipt } from '../Utils'
import { jidNormalizedUser } from '../WABinary'
import makeOrderedDictionary from './make-ordered-dictionary'
@@ -230,6 +230,16 @@ export default (
}
}
})
ev.on('messages.reaction', (reactions) => {
for(const { key, reaction } of reactions) {
const obj = messages[key.remoteJid!]
const msg = obj?.get(key.id!)
if(msg) {
updateMessageWithReaction(msg, reaction)
}
}
})
}
const toJSON = () => ({
@@ -379,4 +389,4 @@ export default (
}
}
}
}
}