fix: sort before splicing when fetching messages
This commit is contained in:
parent
64803c2ba6
commit
4aae8b0f32
1 changed files with 4 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue