mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
feat: added ACK events (#73)
Implements ack change detection, making it possible to know when messages have been delivered, read, etc. Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
committed by
GitHub
parent
1ebaf56617
commit
bb4ad11bfa
@@ -214,6 +214,20 @@ class Client extends EventEmitter {
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onMessageAckEvent', (msg, ack) => {
|
||||
|
||||
const message = new Message(this, msg);
|
||||
|
||||
/**
|
||||
* Emitted when an ack event occurrs on message type.
|
||||
* @event Client#message_ack
|
||||
* @param {Message} message The message that was affected
|
||||
* @param {number} ack The new ACK value
|
||||
*/
|
||||
this.emit(Events.MESSAGE_ACK, message, ack);
|
||||
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => {
|
||||
|
||||
/**
|
||||
@@ -239,6 +253,7 @@ class Client extends EventEmitter {
|
||||
window.Store.Msg.on('add', window.onAddMessageEvent);
|
||||
window.Store.Msg.on('change', window.onChangeMessageEvent);
|
||||
window.Store.Msg.on('change:type', window.onChangeMessageTypeEvent);
|
||||
window.Store.Msg.on('change:ack', window.onMessageAckEvent);
|
||||
window.Store.Msg.on('remove', window.onRemoveMessageEvent);
|
||||
window.Store.AppState.on('change:state', window.onAppStateChangedEvent);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user