summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2024-01-16 04:01:13 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2024-01-16 04:01:13 +0100
commit8ca0f61cadcf469264c05792b3d7d5dd8c252ee9 (patch)
treeb48a996b725fba65a963674b154df7133c256c18
parentFix verification with multiple devices in parallel (diff)
downloadnheko-8ca0f61cadcf469264c05792b3d7d5dd8c252ee9.tar.xz
Disable optimistic pagination to fetch events edited into the thread before the threadroot
fixes #1661
-rw-r--r--src/timeline/TimelineFilter.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/timeline/TimelineFilter.cpp b/src/timeline/TimelineFilter.cpp
index ae7e9791..a933a9e4 100644
--- a/src/timeline/TimelineFilter.cpp
+++ b/src/timeline/TimelineFilter.cpp
@@ -123,7 +123,16 @@ TimelineFilter::fetchAgain()
         return;
 
     if (auto s = source(); s && incrementalSearchIndex == std::numeric_limits<int>::max()) {
-        if (this->rowCount() == cachedCount && s->canFetchMore(QModelIndex()))
+        if (this->rowCount() == cachedCount && s->canFetchMore(QModelIndex()) &&
+            // If we already have the event id of the thread in the timeline and we are filtering by
+            // thread, we can stop fetching more messages In theory an event could have been edited
+            // earlier in the timeline into the thread. So in theory this check is insufficient and
+            // we should instead verify that all events referring to this thread are in the timeline
+            // instead of just the thread root, but only Nheko supports that atm and the check would
+            // be expensive.
+            // TODO(Nico): check that all thread referrencing events are in the timeline by also
+            // checking all edits inside the thread.
+            (threadId.isEmpty() || s->idToIndex(threadId) == -1))
             s->fetchMore(QModelIndex());
         else
             cachedCount = this->rowCount();