mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
updated filters
This commit is contained in:
@@ -95,12 +95,12 @@ 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, searchString?: string) {
|
||||
let db = this.chats
|
||||
if (searchString) {
|
||||
db = db.filter (value => value.name?.includes (searchString) || value.jid?.startsWith(searchString))
|
||||
}
|
||||
const chats = db.paginated (before, count)
|
||||
async loadChats (count: number, before: number | null, filters?: {searchString?: string, archived?: boolean, unread?: 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))
|
||||
)))
|
||||
await Promise.all (
|
||||
chats.map (async chat => (
|
||||
chat.imgUrl === undefined && await this.setProfilePicture (chat)
|
||||
|
||||
Reference in New Issue
Block a user