From b0a4b6c6c10868fad4881fb484b97895ce898b5d Mon Sep 17 00:00:00 2001 From: Sven Date: Mon, 13 Apr 2026 21:05:22 +0200 Subject: [PATCH] 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. --- src/structures/Channel.js | 2 +- src/structures/Chat.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/structures/Channel.js b/src/structures/Channel.js index 7f4bee9..cd3e087 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -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]; } diff --git a/src/structures/Chat.js b/src/structures/Chat.js index 8cea7c1..40211bf 100644 --- a/src/structures/Chat.js +++ b/src/structures/Chat.js @@ -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]; }