Skip to content

Commit

Permalink
feat: select chat group
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Sep 21, 2021
1 parent 65c479d commit 170ab45
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/api/layers/group.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,14 @@ export class GroupLayer extends RetrieverLayer {
/**
* Retrieve all groups
* @returns array of groups
* @param groupId Chat id ('0000000000-00000000@g.us')
*/
public async getAllChatsGroups() {
public async getAllChatsGroups(groupId: string) {
return await this.page.evaluate(() => {
let chats = WAPI.getAllChats();
return chats.filter((chat) => chat.kind === 'group');
const chats = WAPI.getAllChats();
return (!groupId && !groupId.length && typeof groupId === 'string') ?
chats.filter((chat) => chat.kind === 'group') :
chats.filter((chat) => chat.kind === 'group' && groupId === chat.id._serialized);
});
}

Expand Down

0 comments on commit 170ab45

Please sign in to comment.