summary refs log tree commit diff
path: root/src/timeline/TimelineModel.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-05-01 10:19:32 +0200
committerGitHub <noreply@github.com>2020-05-01 10:19:32 +0200
commit38417a374d8b14d3b76d93555dc7d130609212cc (patch)
tree1e3a9f893dd451b5c724523cc6798fedb061b507 /src/timeline/TimelineModel.cpp
parentOld Qt doesn't have .get... (diff)
parentRun linter (diff)
downloadnheko-38417a374d8b14d3b76d93555dc7d130609212cc.tar.xz
Merge pull request #184 from shocklateboy92/features/backlog-progress
Add visual indication that data is being fetched
Diffstat (limited to 'src/timeline/TimelineModel.cpp')
-rw-r--r--src/timeline/TimelineModel.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index d68adf92..340bae39 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -430,14 +430,25 @@ TimelineModel::canFetchMore(const QModelIndex &) const } void +TimelineModel::setPaginationInProgress(const bool paginationInProgress) +{ + if (m_paginationInProgress == paginationInProgress) { + return; + } + + m_paginationInProgress = paginationInProgress; + emit paginationInProgressChanged(m_paginationInProgress); +} + +void TimelineModel::fetchMore(const QModelIndex &) { - if (paginationInProgress) { + if (m_paginationInProgress) { nhlog::ui()->warn("Already loading older messages"); return; } - paginationInProgress = true; + setPaginationInProgress(true); mtx::http::MessagesOpts opts; opts.room_id = room_id_.toStdString(); opts.from = prev_batch_token_.toStdString(); @@ -452,12 +463,13 @@ TimelineModel::fetchMore(const QModelIndex &) mtx::errors::to_string(err->matrix_error.errcode), err->matrix_error.error, err->parse_error); - paginationInProgress = false; + emit oldMessagesRetrieved(std::move(res)); + setPaginationInProgress(false); return; } emit oldMessagesRetrieved(std::move(res)); - paginationInProgress = false; + setPaginationInProgress(false); }); }