From a293146ed82a89039defcfba2e50fa55f676e46f Mon Sep 17 00:00:00 2001 From: Pedro Lopez Date: Mon, 10 Feb 2020 21:44:56 -0400 Subject: [PATCH] fix: added timeout to accepted states This makes the client more reliable since it doesn't quit as soon as it looses conection from the phone for a second. Messages should be queued by WhatsApp Web. --- src/Client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client.js b/src/Client.js index eb12b1b..ec30cb0 100644 --- a/src/Client.js +++ b/src/Client.js @@ -200,8 +200,8 @@ class Client extends EventEmitter { }); - await page.exposeFunction('onAppStateChangedEvent', (AppState, state) => { - const ACCEPTED_STATES = [WAState.CONNECTED, WAState.OPENING, WAState.PAIRING]; + await page.exposeFunction('onAppStateChangedEvent', (_AppState, state) => { + const ACCEPTED_STATES = [WAState.CONNECTED, WAState.OPENING, WAState.PAIRING, WAState.TIMEOUT]; if (!ACCEPTED_STATES.includes(state)) { /** * Emitted when the client has been disconnected