From a1d09e0e21ce276b7324a6ea38f3a4137c8462fb Mon Sep 17 00:00:00 2001 From: victormga Date: Thu, 19 Nov 2020 16:03:39 -0300 Subject: [PATCH] fix: fetchMessages when msgs length is smaller than limit (#438) --- src/structures/Chat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/structures/Chat.js b/src/structures/Chat.js index 13d5af5..8cf1c19 100644 --- a/src/structures/Chat.js +++ b/src/structures/Chat.js @@ -184,7 +184,8 @@ class Chat extends Base { } msgs.sort((a, b) => (a.t > b.t) ? 1 : -1); - return msgs.splice(msgs.length - limit).map(m => window.WWebJS.getMessageModel(m)); + if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit); + return msgs.map(m => window.WWebJS.getMessageModel(m)); }, this.id._serialized, searchOptions.limit);