From 1f9d3024b1893da0ff438ff4ac9e9425e3561c7d Mon Sep 17 00:00:00 2001 From: Lasath Fernando Date: Tue, 28 Apr 2020 02:07:24 -0700 Subject: Add visual indication that data is being fetched This turns `paginationInProgress` field of `TimelineModel` into a `Q_PROPERTY`, so the Ui can bind to it. For the moment, I'm showing the same spinner as we do during initial sync. It's not ideal, on the count of being giant and in the middle but it's better than nothing. We can make it more subtle later. --- src/timeline/TimelineModel.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/timeline/TimelineModel.cpp') diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index e3a1a781..af5bdc82 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -432,15 +432,26 @@ TimelineModel::canFetchMore(const QModelIndex &) const return false; } +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(); @@ -455,12 +466,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); }); } -- cgit 1.5.1