Past events loading (with two bugs)

This commit is contained in:
miruka
2019-07-05 02:45:30 -04:00
parent 83694d387b
commit ecba7c47ec
5 changed files with 83 additions and 29 deletions

View File

@@ -34,15 +34,23 @@ HRectangle {
// reloaded from network.
cacheBuffer: height * 6
// Declaring this "alias" provides the on... signal
// Declaring this as "alias" provides the on... signal
property real yPos: visibleArea.yPosition
property bool canLoad: true
property int zz: 0
onYPosChanged: {
if (chatPage.category != "Invites" && yPos <= 0.1) {
if (chatPage.category != "Invites" && canLoad && yPos <= 0.1) {
zz += 1
print(zz)
//Backend.loadPastEvents(chatPage.roomId)
print(canLoad, zz)
canLoad = false
py.callClientCoro(
chatPage.userId,
"load_past_events",
[chatPage.roomId],
{},
function(more_to_load) { canLoad = more_to_load }
)
}
}
}

View File

@@ -86,13 +86,13 @@ function onTimelineEventReceived(
"senderId": sender_id,
"content": content,
"isLocalEcho": true
}, 1, 500)
}, 1, 250)
if (found.length > 0) {
timelines.set(found[0], item)
} else {
// Multiple clients will emit duplicate events with the same eventId
timelines.upsert({"eventId": event_id}, item, true, 500)
timelines.upsert({"eventId": event_id}, item, true, 250)
}
}