fix: fetchMessages infinite loop when there are no messages in the chat (#1480)

* Fix of fetchMessages

* Node 12 compatibility
This commit is contained in:
jurajmatus 2022-06-14 06:22:53 +02:00 • committed by GitHub
commit 98ff761cfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -184,7 +184,7 @@ class Chat extends Base {
if (searchOptions && searchOptions.limit > 0) { if (searchOptions && searchOptions.limit > 0) {
while (msgs.length < searchOptions.limit) { while (msgs.length < searchOptions.limit) {
const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat); const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat);
if (!loadedMessages) break; if (!loadedMessages || !loadedMessages.length) break;
msgs = [...loadedMessages.filter(msgFilter), ...msgs]; msgs = [...loadedMessages.filter(msgFilter), ...msgs];
} }