From ff54ce9334b03f3e5b9fbee9c7198a99a408bbce Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Wed, 6 May 2020 11:37:40 +0200
Subject: [PATCH] Fix rooms with a lot of reactions not paginating correctly

---
 src/timeline/TimelineModel.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 5e57952ae..75f41d1ec 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -469,7 +469,6 @@ TimelineModel::fetchMore(const QModelIndex &)
                                               mtx::errors::to_string(err->matrix_error.errcode),
                                               err->matrix_error.error,
                                               err->parse_error);
-                          emit oldMessagesRetrieved(std::move(res));
                           setPaginationInProgress(false);
                           return;
                   }
@@ -701,6 +700,11 @@ TimelineModel::addBackwardsEvents(const mtx::responses::Messages &msgs)
         }
 
         prev_batch_token_ = QString::fromStdString(msgs.end);
+
+        if (ids.empty() && !msgs.chunk.empty()) {
+                // no visible events fetched, prevent loading from stopping
+                fetchMore(QModelIndex());
+        }
 }
 
 QString
-- 
GitLab