Skip to content

Commit

Permalink
feat: getAllChatsNewMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Feb 27, 2021
1 parent 04f2200 commit b703462
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,9 @@ const messages = await client.getAllUnreadMessages();
// Retrieve all chats
const chats = await client.getAllChats();

//Retrieves all chats new messages
const chatsAllNew = getAllChatsNewMsg();

// Retrieve all groups
const chats = await client.getAllChatsGroups();

Expand Down
22 changes: 16 additions & 6 deletions src/api/layers/retriever.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,22 @@ export class RetrieverLayer extends SenderLayer {
* Retrieves all chats
* @returns array of [Chat]
*/
public async getAllChats(withNewMessageOnly = false) {
if (withNewMessageOnly) {
return this.page.evaluate(() => WAPI.getAllChatsWithNewMsg());
} else {
return this.page.evaluate(() => WAPI.getAllChats());
}
public async getAllChats() {
return await this.page.evaluate(() => {
let chats = WAPI.getAllChats();
return chats;
});
}

/**
* Retrieves all chats new messages
* @returns array of [Chat]
*/
public async getAllChatsNewMsg() {
return await this.page.evaluate(() => {
let chats = WAPI.getAllChatsWithNewMsg();
return chats;
});
}

/**
Expand Down

0 comments on commit b703462

Please sign in to comment.