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:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user