From 3191784dcb45da1c450240a7e4c6ebd23d2d1055 Mon Sep 17 00:00:00 2001 From: Adhiraj Date: Mon, 7 Sep 2020 12:55:59 +0530 Subject: [PATCH] Update 5.User.ts --- src/WAConnection/5.User.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/WAConnection/5.User.ts b/src/WAConnection/5.User.ts index 5f35d17..2969bc0 100644 --- a/src/WAConnection/5.User.ts +++ b/src/WAConnection/5.User.ts @@ -95,11 +95,10 @@ export class WAConnection extends Base { * @param searchString optionally search for users * @returns the chats & the cursor to fetch the next page */ - async loadChats (count: number, before: number | null, filters?: {searchString?: string, archived?: boolean, unread?: boolean}) { + async loadChats (count: number, before: number | null, filters?: {searchString?: string, custom?: (c: WAChat) => boolean}) { const chats = this.chats.paginated (before, count, filters && (chat => ( - (typeof filters?.archived === 'undefined' || chat.archive === filters.archived.toString()) && - (typeof filters?.searchString === 'undefined' || chat.name?.includes (filters.searchString) || chat.jid?.startsWith(filters.searchString)) && - (typeof filters?.unread === 'undefined' || (filters?.unread ? chat.count !== 0 : chat.count === 0)) + (typeof filters?.custom !== 'function' || filters?.custom(chat)) && + (typeof filters?.searchString === 'undefined' || chat.name?.includes (filters.searchString) || chat.jid?.startsWith(filters.searchString)) ))) await Promise.all ( chats.map (async chat => (