From 98ff761cfb143b3a22873cd385283c95cde8bd71 Mon Sep 17 00:00:00 2001 From: jurajmatus Date: Tue, 14 Jun 2022 06:22:53 +0200 Subject: [PATCH] fix: fetchMessages infinite loop when there are no messages in the chat (#1480) * Fix of fetchMessages * Node 12 compatibility --- src/structures/Chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Chat.js b/src/structures/Chat.js index 26363a8..6f0f0e2 100644 --- a/src/structures/Chat.js +++ b/src/structures/Chat.js @@ -184,7 +184,7 @@ class Chat extends Base { if (searchOptions && searchOptions.limit > 0) { while (msgs.length < searchOptions.limit) { const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat); - if (!loadedMessages) break; + if (!loadedMessages || !loadedMessages.length) break; msgs = [...loadedMessages.filter(msgFilter), ...msgs]; }