Skip to content

Commit a996a43

Browse files
committed
🏷️ upgrade typing in line with pptr 15 breaking changes #2752
1 parent 81c9c6f commit a996a43

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/api/Client.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { default as mime } from 'mime-types';
2-
import { Page, EvaluateFn, PageEventObject, ElementHandle } from 'puppeteer';
2+
import { Page, EvaluateFunc, PageEventObject } from 'puppeteer';
33
import { Chat, LiveLocationChangedEvent, ChatState, ChatMuteDuration, GroupChatCreationResponse, EphemeralDuration } from './model/chat';
44
import { Contact, NumberCheck } from './model/contact';
55
import { Message } from './model/message';
66
import { default as axios, AxiosRequestConfig} from 'axios';
77
import { ParticipantChangedEventModel } from './model/group-metadata';
8-
import { useragent, puppeteerConfig } from '../config/puppeteer.config'
8+
import { useragent } from '../config/puppeteer.config'
99
import { ConfigObject, STATE, LicenseType, Webhook, OnError, EventPayload } from './model';
1010
import { PageEvaluationTimeout, CustomError, ERROR_NAME, AddParticipantError } from './model/errors';
1111
import 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

Comments
 (0)