feat: vote_update event (#2596)
* Merge branch 'add-polls' into polls-ext * added listener to poll votes * added isUnvote property * added option for custom message secret * usage example updated * added logic for catching removed votes * usage example updated * fixed logic for poll vote events * temp usage example * No more `isCurrentState` * messageSecret converted to array Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com> * docs updated * we already have messageSecret in vote.parentMessage * PollVote.selectedOptions changed to be similar to pollOptions * docs fixed * window.injectToFunction clarifications * minor clarifications * fix: typo * style: fix broken link in readme file --------- Co-authored-by: tuyuribr <45042245+tuyuribr@users.noreply.github.com>
This commit is contained in:
parent
8c810a8462
commit
01714fe599
1 changed files with 132 additions and 3 deletions
36
index.d.ts
vendored
36
index.d.ts
vendored
|
|
@ -371,6 +371,14 @@ declare namespace WAWebJS {
|
|||
|
||||
/** Emitted when the RemoteAuth session is saved successfully on the external Database */
|
||||
on(event: 'remote_session_saved', listener: () => void): this
|
||||
|
||||
/**
|
||||
* Emitted when some poll option is selected or deselected,
|
||||
* shows a user's current selected option(s) on the poll
|
||||
*/
|
||||
on(event: 'vote_update', listener: (
|
||||
vote: PollVote
|
||||
) => void): this
|
||||
}
|
||||
|
||||
/** Current connection information */
|
||||
|
|
@ -1018,6 +1026,34 @@ declare namespace WAWebJS {
|
|||
constructor(pollName: string, pollOptions: Array<string>, options?: PollSendOptions)
|
||||
}
|
||||
|
||||
/** Represents a Poll Vote on WhatsApp */
|
||||
export interface PollVote {
|
||||
/** The person who voted */
|
||||
voter: string;
|
||||
|
||||
/**
|
||||
* The selected poll option(s)
|
||||
* If it's an empty array, the user hasn't selected any options on the poll,
|
||||
* may occur when they deselected all poll options
|
||||
*/
|
||||
selectedOptions: SelectedPollOption[];
|
||||
|
||||
/** Timestamp the option was selected or deselected at */
|
||||
interractedAtTs: number;
|
||||
|
||||
/** The poll creation message associated with the poll vote */
|
||||
parentMessage: Message;
|
||||
}
|
||||
|
||||
/** Selected poll option structure */
|
||||
export interface SelectedPollOption {
|
||||
/** The local selected option ID */
|
||||
id: number;
|
||||
|
||||
/** The option name */
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Label {
|
||||
/** Label name */
|
||||
name: string,
|
||||
|
|
|
|||
Loading…
Reference in a new issue