From 796a0a2367cf997a1f73a1de765a8e2787fb4125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernardo=20Pe=C3=B1a?= Date: Mon, 23 Sep 2024 10:14:41 -0400 Subject: [PATCH] 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> --- src/Client.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Client.js b/src/Client.js index e51810c..e9f5d12 100644 --- a/src/Client.js +++ b/src/Client.js @@ -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)); });