Skip to content

Commit

Permalink
feat: Added onRevokedMessage (close #434)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Oct 12, 2021
1 parent 89eeb37 commit b5df5bb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/api/layers/listener.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class ListenerLayer extends ProfileLayer {
...Object.values(ExposedFn),
'onAddedToGroup',
'onIncomingCall',
'onRevokedMessage',
];

for (const func of functions) {
Expand Down Expand Up @@ -129,6 +130,20 @@ export class ListenerLayer extends ProfileLayer {
window.WAPI.onLiveLocation(window['onLiveLocation']);
window['onLiveLocation'].exposed = true;
}
if (!window['onRevokedMessage'].exposed) {
// @ts-ignore
WPP.chat.on('msg_revoke', (data: any) => {
const eventData = {
author: data.author,
from: data.from,
to: data.to,
id: data.id._serialized,
refId: data.refId._serialized,
};
window['onRevokedMessage'](eventData);
});
window['onRevokedMessage'].exposed = true;
}
})
.catch(() => {});
}
Expand Down Expand Up @@ -422,4 +437,20 @@ export class ListenerLayer extends ProfileLayer {
id
);
}

/**
* @event Listens to revoked messages
* @returns Disposable object to stop the listening
*/
public onRevokedMessage(
callback: (data: {
author?: string;
from: string;
to: string;
id: string;
refId: String;
}) => any
) {
return this.registerEvent('onRevokedMessage', callback);
}
}

0 comments on commit b5df5bb

Please sign in to comment.