aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-17 13:00:36 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-17 13:00:36 +0900
commit0f43e74bcf06b2b09018d564a73aa931098eb790 (patch)
treeab93438a04bf91c4a78f279587eca043ab4cf697
parentada271e47071681848fdbdecd3aecaa9073091b4 (diff)
downloadlibquotient-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.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/room.cpp b/room.cpp
index bec4cd30..8ab5b7f5 100644
--- a/room.cpp
+++ b/room.cpp
@@ -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());
});
}
}