Skip to content

Commit

Permalink
fix: Improved onMessage event to re-trigger message after ciphertext (f…
Browse files Browse the repository at this point in the history
…ix #1065)
  • Loading branch information
edgardmessias committed Jul 11, 2022
1 parent 8ecaa6b commit b9ff808
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/api/layers/listener.layer.ts
Expand Up @@ -102,11 +102,14 @@ export class ListenerLayer extends ProfileLayer {
.evaluate(() => {
try {
if (!window['onMessage'].exposed) {
window.WAPI.waitNewMessages(false, (data) => {
data.forEach((message) => {
window['onMessage'](message);
});
WPP.on('chat.new_message', (msg) => {
if (msg.isSentByMe || msg.isStatusV3) {
return;
}
const serialized = WAPI.processMessageObj(msg, false, false);
window['onMessage'](serialized);
});

window['onMessage'].exposed = true;
}
} catch (error) {
Expand Down
5 changes: 5 additions & 0 deletions src/types/WAPI.d.ts
Expand Up @@ -202,6 +202,11 @@ interface WAPI {
waitNewMessages: (rmCallback: boolean, callback: Function) => void;
_profilePicfunc: (contactId: string) => Promise<ProfilePicThumbObj>;
_serializeChatObj: (chat: any) => any;
processMessageObj: (
messageObj: any,
includeMe: boolean,
includeNotifications: boolean
) => any;
}

declare global {
Expand Down

0 comments on commit b9ff808

Please sign in to comment.