update typings for fetchMessages changes

This commit is contained in:
Pedro Lopez
2022-02-06 19:30:13 -04:00
parent aa9e19a19e
commit 64803c2ba6
2 changed files with 2 additions and 3 deletions

3
index.d.ts vendored
View File

@@ -930,10 +930,9 @@ declare namespace WAWebJS {
export interface MessageSearchOptions {
/**
* The amount of messages to return.
* The amount of messages to return. If no limit is specified, the available messages will be returned.
* Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
* Set this to Infinity to load all messages.
* @default 50
*/
limit?: number
}

View File

@@ -181,7 +181,7 @@ class Chat extends Base {
const chat = window.Store.Chat.get(chatId);
let msgs = chat.msgs.models.filter(msgFilter);
if (searchOptions && searchOptions.limit) {
if (searchOptions && searchOptions.limit > 0) {
while (msgs.length < searchOptions.limit) {
const loadedMessages = await chat.loadEarlierMsgs();
if (!loadedMessages) break;