Maybe fix message sorting

This commit is contained in:
Andrew Ferrazzutti 2021-04-06 01:54:45 -04:00
parent fc8bc79ffd
commit 935bc6bdb8
2 changed files with 3 additions and 3 deletions

View File

@ -393,6 +393,8 @@ class Portal(DBPortal, BasePortal):
max_mid = await DBMessage.get_max_mid(self.mxid) or 0
messages = [msg for msg in await source.client.get_messages(self.chat_id)
if msg.id > max_mid]
# TODO Confirm why sorting in Node isn't enough
messages.sort(key=lambda message: message.id)
if not messages:
self.log.debug("Didn't get any entries from server")

View File

@ -584,9 +584,7 @@ export default class MessagesPuppeteer {
this.log("Waiting for messages to load")
const messages = await this.page.evaluate(
id => window.__mautrixController.parseMessageList(id), id)
return messages.
filter(msg => msg.id > minID && !this.sentMessageIDs.has(msg.id)).
sort((a,b) => a.id - b.id) // TODO Confirm whether this sort is really needed
return messages.filter(msg => msg.id > minID && !this.sentMessageIDs.has(msg.id))
}
async _processChatListChangeUnsafe(id) {