forked from danielcardeenas/sulla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.layer.ts
40 lines (36 loc) Β· 982 Bytes
/
ui.layer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Page } from 'puppeteer';
import { GroupLayer } from './group.layer';
declare module WAPI {
const openChat: (chatId: string) => boolean;
const openChatAt: (
chatId: string,
messageId: string
) => { wasVisible: boolean; alignAt: string };
}
export class UILayer extends GroupLayer {
constructor(page: Page) {
super(page);
}
/**
* Opens given chat at last message (bottom)
* Will fire natural workflow events of whatsapp web
* @param chatId
*/
public async openChat(chatId: string) {
return this.page.evaluate(
(chatId: string) => WAPI.openChat(chatId),
chatId
);
}
/**
* Opens chat at given message position
* @param chatId Chat id
* @param messageId Message id (For example: '06D3AB3D0EEB9D077A3F9A3EFF4DD030')
*/
public async openChatAt(chatId: string, messageId: string) {
return this.page.evaluate(
(chatId: string) => WAPI.openChatAt(chatId, messageId),
chatId
);
}
}