Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated methods #320

Merged
merged 3 commits into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/puppet-whatsapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,21 @@ class PuppetWhatsapp extends PUPPET.Puppet {
private async onLogin (wxid: string): Promise<void> {
log.verbose(PRE, 'onLogin(%s)', wxid)

if (this.logonoff()) {
if (this.isLoggedIn) {
log.warn(PRE, 'onLogin(%s) already login? NOOP', wxid)
return
}
log.info(PRE, `${EventName.LOGIN}, ${wxid}`)

if (!this.selfId()) {
await super.login(wxid)
} else {
this.emit('login', { contactId: wxid })
}
await super.login(wxid)
// no need to emit login since super.login will do that
// this.emit('login', { contactId: wxid })
}

private async onLogout (wxid: string, message: string): Promise<void> {
log.verbose(PRE, 'onLogout(%s, %s)', wxid, message)

if (!this.logonoff()) {
if (!this.isLoggedIn) {
log.warn(PRE, 'onLogout(%s) already logged out?', wxid)
}
log.info(PRE, `${EventName.LOGOUT}, ${wxid}`)
Expand Down Expand Up @@ -238,6 +236,7 @@ class PuppetWhatsapp extends PUPPET.Puppet {
}

override async logout () {
await super.logout()
if (!this.isLoggedIn) {
log.verbose(PRE, 'logout() do nothing')
return
Expand Down