Skip to content

Commit

Permalink
feat: Added onReactionMessage event
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta committed Jul 19, 2022
1 parent b727260 commit 2c25b01
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/api/layers/listener.layer.ts
Expand Up @@ -81,6 +81,7 @@ export class ListenerLayer extends ProfileLayer {
'onAddedToGroup',
'onIncomingCall',
'onRevokedMessage',
'onReactionMessage',
];

for (const func of functions) {
Expand Down Expand Up @@ -219,6 +220,25 @@ export class ListenerLayer extends ProfileLayer {
} catch (error) {
console.error(error);
}
try {
if (!window['onReactionMessage'].exposed) {
WPP.on('chat.new_reaction', (data) => {
const eventData = {
id: data.id,
msgId: data.msgId,
reactionText: data.reactionText,
read: data.read,
orphan: data.orphan,
orphanReason: data.orphanReason,
timestamp: data.timestamp,
};
window['onReactionMessage'](eventData);
});
window['onReactionMessage'].exposed = true;
}
} catch (error) {
console.error(error);
}
})
.catch(() => {});
}
Expand Down Expand Up @@ -528,4 +548,22 @@ export class ListenerLayer extends ProfileLayer {
) {
return this.registerEvent('onRevokedMessage', callback);
}

/**
* @event Listens to reaction messages
* @returns Disposable object to stop the listening
*/
public onReactionMessage(
callback: (data: {
id: string;
msgId: string;
reactionText: string;
read: boolean;
orphan: number;
orphanReason: any;
timestamp: number;
}) => any
) {
return this.registerEvent('onReactionMessage', callback);
}
}

0 comments on commit 2c25b01

Please sign in to comment.