forked from fair/matrix-puppeteer-line
Maybe fix message sorting
This commit is contained in:
parent
fc8bc79ffd
commit
935bc6bdb8
|
@ -393,6 +393,8 @@ class Portal(DBPortal, BasePortal):
|
||||||
max_mid = await DBMessage.get_max_mid(self.mxid) or 0
|
max_mid = await DBMessage.get_max_mid(self.mxid) or 0
|
||||||
messages = [msg for msg in await source.client.get_messages(self.chat_id)
|
messages = [msg for msg in await source.client.get_messages(self.chat_id)
|
||||||
if msg.id > max_mid]
|
if msg.id > max_mid]
|
||||||
|
# TODO Confirm why sorting in Node isn't enough
|
||||||
|
messages.sort(key=lambda message: message.id)
|
||||||
|
|
||||||
if not messages:
|
if not messages:
|
||||||
self.log.debug("Didn't get any entries from server")
|
self.log.debug("Didn't get any entries from server")
|
||||||
|
|
|
@ -584,9 +584,7 @@ export default class MessagesPuppeteer {
|
||||||
this.log("Waiting for messages to load")
|
this.log("Waiting for messages to load")
|
||||||
const messages = await this.page.evaluate(
|
const messages = await this.page.evaluate(
|
||||||
id => window.__mautrixController.parseMessageList(id), id)
|
id => window.__mautrixController.parseMessageList(id), id)
|
||||||
return messages.
|
return messages.filter(msg => msg.id > minID && !this.sentMessageIDs.has(msg.id))
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _processChatListChangeUnsafe(id) {
|
async _processChatListChangeUnsafe(id) {
|
||||||
|
|
Loading…
Reference in New Issue