Update Client.js (#3286)

fix: resolved issue with 'onPollVoteEvent' binding after logout

- Fixed error: 'Failed to add page binding with name onPollVoteEvent: window["onPollVoteEvent"] already exists!'
- The error occurred after logging out and attempting to reconnect.
- Connection would get stuck in 'authenticated' state and never reach 'ready'.

Co-authored-by: alechkos <93551621+alechkos@users.noreply.github.com>
This commit is contained in:
Bernardo Peña 2024-09-23 10:14:41 -04:00 • committed by GitHub
commit 796a0a2367
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -685,17 +685,17 @@ class Client extends EventEmitter {
*/
this.emit(Events.MESSAGE_CIPHERTEXT, new Message(this, msg));
});
}
await this.pupPage.exposeFunction('onPollVoteEvent', (vote) => {
const _vote = new PollVote(this, vote);
/**
* Emitted when some poll option is selected or deselected,
* shows a user's current selected option(s) on the poll
* @event Client#vote_update
*/
this.emit(Events.VOTE_UPDATE, _vote);
});
await this.pupPage.exposeFunction('onPollVoteEvent', (vote) => {
const _vote = new PollVote(this, vote);
/**
* Emitted when some poll option is selected or deselected,
* shows a user's current selected option(s) on the poll
* @event Client#vote_update
*/
this.emit(Events.VOTE_UPDATE, _vote);
});
}
await this.pupPage.evaluate(() => {
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });