From a88a82ca08fe3117ab757af40c8b2dbb179a3789 Mon Sep 17 00:00:00 2001 From: Arno Rehn Date: Sun, 28 Sep 2025 20:35:54 +0200 Subject: [PATCH] PollHandler: Correctly handle paginated events --- src/messagecontent/pollhandler.cpp | 9 +++++++-- src/messagecontent/pollhandler.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/messagecontent/pollhandler.cpp b/src/messagecontent/pollhandler.cpp index 766ec6df0..a1f9b3122 100644 --- a/src/messagecontent/pollhandler.cpp +++ b/src/messagecontent/pollhandler.cpp @@ -41,17 +41,22 @@ void PollHandler::updatePoll(Quotient::RoomEventsRange events) } } -void PollHandler::checkLoadRelations() +void PollHandler::checkLoadRelations(const QString &nextBatch) { const auto pollStartEvent = m_room->getEvent(m_pollStartId).first; if (pollStartEvent == nullptr) { return; } - m_room->connection()->callApi(m_room->id(), pollStartEvent->id()).onResult([this](const auto &job) { + m_room->connection()->callApi(m_room->id(), pollStartEvent->id(), nextBatch).onResult([this](const auto &job) { for (const auto &event : job->chunk()) { handleEvent(event.get()); } + + // This is paginated API. If it indicates that there's more data, run again starting from the supplied pagination token. + if (!job->nextBatch().isEmpty()) { + checkLoadRelations(job->nextBatch()); + } }); } diff --git a/src/messagecontent/pollhandler.h b/src/messagecontent/pollhandler.h index 66cedd185..811426976 100644 --- a/src/messagecontent/pollhandler.h +++ b/src/messagecontent/pollhandler.h @@ -128,7 +128,7 @@ private: void updatePoll(Quotient::RoomEventsRange events); - void checkLoadRelations(); + void checkLoadRelations(const QString &nextBatch = {}); void handleEvent(Quotient::RoomEvent *event); void handleResponse(const Quotient::PollResponseEvent *event); QHash m_selectionTimestamps;