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::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();