Fix: Event Call (#201714)

* Fix: Event Call

* Update Client.js
This commit is contained in:
BenyFilho 2026-04-16 13:14:53 -03:00 • committed by GitHub
commit 33f88ac150
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1020,8 +1020,7 @@ class Client extends EventEmitter {
);
await this.pupPage.evaluate(() => {
const { Msg, Chat, WAWebCallCollection } =
window.require('WAWebCollections');
const { Msg, Chat } = window.require('WAWebCollections');
const AppState = window.require('WAWebSocketModel').Socket;
// Enable placeholder message resend (recovery for ciphertext messages)
@ -1069,13 +1068,31 @@ class Client extends EventEmitter {
.Conn.on('change:battery', (state) => {
window.onBatteryStateChangedEvent(state);
});
const WAWebCallCollection = window.require('WAWebCallCollection');
if (
WAWebCallCollection &&
typeof WAWebCallCollection.on === 'function'
) {
WAWebCallCollection.on('add', (call) => {
window.onIncomingCall(call);
});
const mapKey = Object.keys(WAWebCallCollection).find(
(k) => WAWebCallCollection[k] instanceof Map,
);
const internalCallMap = WAWebCallCollection[mapKey];
const originalMapSet =
internalCallMap.set.bind(internalCallMap);
internalCallMap.set = function (key, value) {
window.onIncomingCall({
id: value.id,
peerJid: value.peerJid,
isVideo: value.isVideo,
isGroup: value.isGroup,
canHandleLocally: value.canHandleLocally,
outgoing: value.outgoing,
webClientShouldHandle: value.webClientShouldHandle,
participants: value.participants,
});
return originalMapSet(key, value);
};
}
Chat.on('remove', async (chat) => {
window.onRemoveChatEvent(