diff --git a/src/models/threadmodel.cpp b/src/models/threadmodel.cpp index 471acab66..f553d6275 100644 --- a/src/models/threadmodel.cpp +++ b/src/models/threadmodel.cpp @@ -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(QObject::parent()); + if (room == nullptr) { + return; + } + + for (auto i = room->pendingEvents().rbegin(); i != room->pendingEvents().rend(); i++) { + if (const auto roomMessageEvent = eventCast(i->event()); + roomMessageEvent->isThreaded() && roomMessageEvent->threadRootEventId() == m_threadRootId) { + addNewEvent(roomMessageEvent); + } + } +} + QString ThreadModel::threadRootId() const { return m_threadRootId; diff --git a/src/models/threadmodel.h b/src/models/threadmodel.h index 7105765e2..0a24f3f09 100644 --- a/src/models/threadmodel.h +++ b/src/models/threadmodel.h @@ -135,6 +135,7 @@ private: std::optional m_nextBatch = QString(); bool m_addingPending = false; + void checkPending(); void addNewEvent(const Quotient::RoomEvent *event); void addModels(); void clearModels();