fix(structures): use loadEarlierMsgs options signature in fetchMessages (#201713)

WhatsApp Web changed the signature of WAWebChatLoadMessages.loadEarlierMsgs
from positional (chat, msgCollection) to an options object
{chat, msgCollection, signal, threadId, trigger}.

Calling the old positional form crashes with "Cannot read properties of
undefined (reading 'waitForChatLoading')" because the destructure reads
e.chat on the first positional argument instead of treating the first
argument as the chat.

Updates both Chat.fetchMessages and Channel.fetchMessages to pass the
options object. No other behaviour change.
This commit is contained in:
Sven 2026-04-13 21:05:22 +02:00 • committed by GitHub
commit b0a4b6c6c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -353,7 +353,7 @@ class Channel extends Base {
while (msgs.length < searchOptions.limit) {
const loadedMessages = await window
.require('WAWebChatLoadMessages')
.loadEarlierMsgs(channel);
.loadEarlierMsgs({ chat: channel });
if (!loadedMessages || !loadedMessages.length) break;
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
}

View file

@ -226,7 +226,7 @@ class Chat extends Base {
while (msgs.length < searchOptions.limit) {
const loadedMessages = await window
.require('WAWebChatLoadMessages')
.loadEarlierMsgs(chat, chat.msgs);
.loadEarlierMsgs({ chat });
if (!loadedMessages || !loadedMessages.length) break;
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
}