Skip to content

Commit b0a4b6c

Browse files
authored
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.
1 parent 11594b2 commit b0a4b6c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/structures/Channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class Channel extends Base {
353353
while (msgs.length < searchOptions.limit) {
354354
const loadedMessages = await window
355355
.require('WAWebChatLoadMessages')
356-
.loadEarlierMsgs(channel);
356+
.loadEarlierMsgs({ chat: channel });
357357
if (!loadedMessages || !loadedMessages.length) break;
358358
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
359359
}

src/structures/Chat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class Chat extends Base {
226226
while (msgs.length < searchOptions.limit) {
227227
const loadedMessages = await window
228228
.require('WAWebChatLoadMessages')
229-
.loadEarlierMsgs(chat, chat.msgs);
229+
.loadEarlierMsgs({ chat });
230230
if (!loadedMessages || !loadedMessages.length) break;
231231
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
232232
}

0 commit comments

Comments
 (0)