-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4955e07
commit 76da1b1
Showing
11 changed files
with
93 additions
and
40 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
export function openChat(chatId) {} | ||
/** | ||
* Opens chat as UI, will fire natural workflow events of whatsapp web | ||
* This is a UI proccess, use this in a queue | ||
* @param {string} chatId chat id | ||
* @returns {boolean} | ||
*/ | ||
export async function openChat(chatId) { | ||
const chat = Store.Chat.get(chatId); | ||
const result = Store.Cmd.default.openChatBottom(chat); | ||
return result; | ||
} | ||
|
||
/** | ||
* Opens chat at given message position | ||
* This is a UI proccess, use this in a queue | ||
* @param {string} chatId Chat id | ||
* @param {string} messageId Message id: (For example: '06D3AB3D0EEB9D077A3F9A3EFF4DD030') | ||
* @returns {{wasVisible: boolean, alignAt: string}}: {wasVisible: false, alignAt: "center"} | ||
*/ | ||
export async function openChatAt(chatId, messageId) { | ||
const chat = Store.Chat.get(chatId); | ||
const atMessage = chat.msgs.models.find((model) => model.id.id === messageId); | ||
const args = { | ||
collection: chat.msgs, | ||
msg: atMessage, | ||
isUnreadDivider: false, | ||
}; | ||
const result = await Store.Cmd.default._openChat(chat, args); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters