diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-12-23 13:50:11 +0200 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-12-23 13:50:11 +0200 |
commit | 9d763c4de9d4820361140adcdda3f60977da2950 (patch) | |
tree | b132b8f74653a187274548fe6344af4779964ba4 /src/timeline | |
parent | Don't create artifacts when we're not deploying (diff) | |
download | nheko-9d763c4de9d4820361140adcdda3f60977da2950.tar.xz |
Don't keep fetching history on non-visible timelines
If the user switched to another timeline before the current timeline filled up with messages, nheko would keep fetching history. Now it will check periodically if the timeline became visible so it can decide whether or not to stop fetching history.
Diffstat (limited to 'src/timeline')
-rw-r--r-- | src/timeline/TimelineView.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/timeline/TimelineView.cc b/src/timeline/TimelineView.cc index dd51fc52..dccc6f37 100644 --- a/src/timeline/TimelineView.cc +++ b/src/timeline/TimelineView.cc @@ -21,7 +21,6 @@ #include "FloatingButton.h" #include "RoomMessages.h" -#include "ScrollBar.h" #include "timeline/TimelineView.h" #include "timeline/widgets/AudioItem.h" @@ -83,12 +82,18 @@ TimelineView::sliderRangeChanged(int min, int max) void TimelineView::fetchHistory() { - bool hasEnoughMessages = scroll_area_->verticalScrollBar()->isVisible(); + if (!isScrollbarActivated() && !isTimelineFinished) { + if (!isVisible()) { + // Check again later if the timeline became visible. + // TODO: Use a backoff strategy. + paginationTimer_->start(3000); + return; + } - if (!hasEnoughMessages && !isTimelineFinished) { isPaginationInProgress_ = true; client_->messages(room_id_, prev_batch_token_); - paginationTimer_->start(500); + paginationTimer_->start(1500); + return; } |