mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
fix: sort before splicing when fetching messages
This commit is contained in:
@@ -187,11 +187,13 @@ class Chat extends Base {
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
if (msgs.length > searchOptions.limit)
|
||||
|
||||
if (msgs.length > searchOptions.limit) {
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
||||
}
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions);
|
||||
|
||||
Reference in New Issue
Block a user