Skip to content

Commit

Permalink
Update Client.js (#3286)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bpena and alechkos committed Sep 23, 2024
1 parent 5b0e061 commit 796a0a2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)); });
Expand Down

0 comments on commit 796a0a2

Please sign in to comment.