fix: fetchMessages when msgs length is smaller than limit (#438)

This commit is contained in:
victormga
2020-11-19 16:03:39 -03:00
committed by GitHub
parent d86ccec5d1
commit a1d09e0e21

View File

@@ -184,7 +184,8 @@ class Chat extends Base {
} }
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1); 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); }, this.id._serialized, searchOptions.limit);