Fix new thread loading

If a thread was created by the local user fetchMore() won't find the pending event that created it so make sure it is found and added.
This commit is contained in:
James Graham
2024-12-24 16:20:49 +00:00
parent 2d3373efbb
commit 0f79c04d93
2 changed files with 19 additions and 0 deletions

View File

@@ -46,10 +46,28 @@ ThreadModel::ThreadModel(const QString &threadRootId, NeoChatRoom *room)
addModels();
});
// If the thread was created by the local user fetchMore() won't find the current
// pending event.
checkPending();
fetchMore({});
addModels();
}
void ThreadModel::checkPending()
{
const auto room = dynamic_cast<NeoChatRoom *>(QObject::parent());
if (room == nullptr) {
return;
}
for (auto i = room->pendingEvents().rbegin(); i != room->pendingEvents().rend(); i++) {
if (const auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(i->event());
roomMessageEvent->isThreaded() && roomMessageEvent->threadRootEventId() == m_threadRootId) {
addNewEvent(roomMessageEvent);
}
}
}
QString ThreadModel::threadRootId() const
{
return m_threadRootId;

View File

@@ -135,6 +135,7 @@ private:
std::optional<QString> m_nextBatch = QString();
bool m_addingPending = false;
void checkPending();
void addNewEvent(const Quotient::RoomEvent *event);
void addModels();
void clearModels();