11import { default as mime } from 'mime-types' ;
2- import { Page , EvaluateFn , PageEventObject , ElementHandle } from 'puppeteer' ;
2+ import { Page , EvaluateFunc , PageEventObject } from 'puppeteer' ;
33import { Chat , LiveLocationChangedEvent , ChatState , ChatMuteDuration , GroupChatCreationResponse , EphemeralDuration } from './model/chat' ;
44import { Contact , NumberCheck } from './model/contact' ;
55import { Message } from './model/message' ;
66import { default as axios , AxiosRequestConfig } from 'axios' ;
77import { ParticipantChangedEventModel } from './model/group-metadata' ;
8- import { useragent , puppeteerConfig } from '../config/puppeteer.config'
8+ import { useragent } from '../config/puppeteer.config'
99import { ConfigObject , STATE , LicenseType , Webhook , OnError , EventPayload } from './model' ;
1010import { PageEvaluationTimeout , CustomError , ERROR_NAME , AddParticipantError } from './model/errors' ;
1111import PQueue , { DefaultAddOptions , Options } from 'p-queue' ;
@@ -528,7 +528,7 @@ export class Client {
528528 }
529529
530530
531- private async pup ( pageFunction :EvaluateFn < any > , ...args ) {
531+ private async pup ( pageFunction :EvaluateFunc < any > , ...args ) {
532532 const invocation_id = uuidv4 ( ) . slice ( - 5 ) ;
533533 const { safeMode, callTimeout, idCorrection, logging} = this . _createConfig ;
534534 let _t : number ;
@@ -1288,13 +1288,14 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom
12881288 *
12891289 * [[Detecting Logouts]]
12901290 */
1291- public async forceRefocus ( ) : Promise < void > {
1291+ public async forceRefocus ( ) : Promise < boolean > {
12921292 const useHere : string = await this . _page . evaluate ( ( ) => WAPI . getUseHereString ( ) ) ;
12931293 await this . _page . waitForFunction (
12941294 `[...document.querySelectorAll("div[role=button")].find(e=>{return e.innerHTML.toLowerCase().includes("${ useHere . toLowerCase ( ) } ")})` ,
12951295 { timeout : 0 }
12961296 ) ;
1297- return await this . _page . evaluate ( `[...document.querySelectorAll("div[role=button")].find(e=>{return e.innerHTML.toLowerCase().includes("${ useHere . toLowerCase ( ) } ")}).click()` ) ;
1297+ await this . _page . evaluate ( `[...document.querySelectorAll("div[role=button")].find(e=>{return e.innerHTML.toLowerCase().includes("${ useHere . toLowerCase ( ) } ")}).click()` ) ;
1298+ return true ;
12981299 }
12991300
13001301 /**
@@ -1304,6 +1305,7 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom
13041305 */
13051306 public async isPhoneDisconnected ( ) : Promise < boolean > {
13061307 const phoneNotConnected : string = await this . _page . evaluate ( ( ) => WAPI . getLocaledString ( 'active Internet connection' ) ) ;
1308+ //@ts -ignore
13071309 return await this . pup ( `!![...document.querySelectorAll("div")].find(e=>{return e.innerHTML.toLowerCase().includes("${ phoneNotConnected . toLowerCase ( ) } ")})` )
13081310 }
13091311
@@ -1973,7 +1975,7 @@ public async testCallback(callbackToTest: SimpleListener, testData: any) : Prom
19731975 const snapshotElement = chatId ? ( await this . _page . evaluateHandle (
19741976 ( { chatId } ) => WAPI . getSnapshotElement ( chatId ) ,
19751977 { chatId }
1976- ) as ElementHandle ) : this . getPage ( )
1978+ ) as any ) : this . getPage ( )
19771979 const screenshot = await snapshotElement . screenshot ( {
19781980 type :"png" ,
19791981 encoding : "base64"
0 commit comments