diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-17 13:00:36 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-17 13:00:36 +0900 |
commit | 0f43e74bcf06b2b09018d564a73aa931098eb790 (patch) | |
tree | ab93438a04bf91c4a78f279587eca043ab4cf697 | |
parent | ada271e47071681848fdbdecd3aecaa9073091b4 (diff) | |
download | libquotient-0f43e74bcf06b2b09018d564a73aa931098eb790.tar.gz libquotient-0f43e74bcf06b2b09018d564a73aa931098eb790.zip |
Room::getPreviousContent(): Don't skip if the last job just finished
working
The sequence is: RoomMessagesJob::success -> addHistoricalMessageEvents
-> MessageEventModel notification -> QML notification about model reset
-> MessageEventModel completes updating -> QML updates from the model
but by then scrolling has already stopped at the oldest (just loaded)
event -> since there's no momentum, next batch is not fetched. In order
to address this, two things are done: in QML, the current position is
checked in modelReset() handler; in Room (this commit), prev_batch is
updated before historical messages are added (and the model gets
notified, respectively), to prevent firing another job with the old
prev_batch.
-rw-r--r-- | room.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -744,17 +744,13 @@ void Room::getPreviousContent(int limit) void Room::Private::getPreviousContent(int limit) { - if( !roomMessagesJob ) + if( !isJobRunning(roomMessagesJob) ) { roomMessagesJob = connection->callApi<RoomMessagesJob>(id, prevBatch, limit); - connect( roomMessagesJob, &RoomMessagesJob::result, [=] { - if( !roomMessagesJob->error() ) - { - addHistoricalMessageEvents(roomMessagesJob->releaseEvents()); - prevBatch = roomMessagesJob->end(); - } - roomMessagesJob = nullptr; + connect( roomMessagesJob, &RoomMessagesJob::success, [=] { + prevBatch = roomMessagesJob->end(); + addHistoricalMessageEvents(roomMessagesJob->releaseEvents()); }); } } |