PollHandler: Correctly handle paginated events

This commit is contained in:
Arno Rehn
2025-09-28 20:35:54 +02:00
parent 23dc88df60
commit a88a82ca08
2 changed files with 8 additions and 3 deletions

View File

@@ -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<GetRelatingEventsJob>(m_room->id(), pollStartEvent->id()).onResult([this](const auto &job) {
m_room->connection()->callApi<GetRelatingEventsJob>(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());
}
});
}

View File

@@ -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<QString, QDateTime> m_selectionTimestamps;