Skip to content

Commit

Permalink
feat: Improovment WPP.chat.list for list Newsletters
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelo386 committed Apr 2, 2024
1 parent 2d0b9af commit 6d3efed
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/chat/functions/list.ts
@@ -1,5 +1,5 @@
/*!
* Copyright 2023 WPPConnect Team
* Copyright 2024 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@ import {
ChatStore,
GroupMetadataStore,
LabelStore,
NewsletterStore,
Wid,
} from '../../whatsapp';
import { get } from './get';
Expand All @@ -29,6 +30,7 @@ export interface ChatListOptions {
direction?: 'after' | 'before';
onlyCommunities?: boolean;
onlyGroups?: boolean;
onlyNewsletter?: boolean;
onlyUsers?: boolean;
onlyWithUnreadMessage?: boolean;
withLabels?: string[];
Expand Down Expand Up @@ -57,6 +59,9 @@ export interface ChatListOptions {
* // Only communities chats
* const chats = await WPP.chat.list({onlyCommunities: true});
*
* // Only Newsletter
* const chats = await WPP.chat.list({onlyNewsletter: true});
*
* // Only with label Text
* const chats = await WPP.chat.list({withLabels: ['Test']});
*
Expand All @@ -78,7 +83,9 @@ export async function list(

// Getting All Chats.
// IDK, why we use slice here. don't think its needed.
let models = ChatStore.getModelsArray().slice();
let models = options.onlyNewsletter
? NewsletterStore.getModelsArray().slice()
: ChatStore.getModelsArray().slice();

// Filtering Based on Options.
if (options.onlyUsers) {
Expand Down

0 comments on commit 6d3efed

Please sign in to comment.