From 314f86007ebcab090ced178d622a28c5e87f924d Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 22 Dec 2024 10:11:56 +0000 Subject: [PATCH] Fix New ThreadModel Messages ThreadModel was not updated to use pendingEventAdded the same way MessageEventModel was so new messages in an exisiting thread were not being initialised properly. This fixes it to use the updated pendingEventAdded on new enough versions of libQuotient. --- src/models/threadmodel.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/models/threadmodel.cpp b/src/models/threadmodel.cpp index a2fddaf36..17ded8f0e 100644 --- a/src/models/threadmodel.cpp +++ b/src/models/threadmodel.cpp @@ -23,7 +23,11 @@ ThreadModel::ThreadModel(const QString &threadRootId, NeoChatRoom *room) m_threadRootContentModel = std::unique_ptr(new MessageContentModel(room, threadRootId)); +#if Quotient_VERSION_MINOR > 9 || (Quotient_VERSION_MINOR == 9 && Quotient_VERSION_PATCH > 0) + connect(room, &Quotient::Room::pendingEventAdded, this, [this](const Quotient::RoomEvent *event) { +#else connect(room, &Quotient::Room::pendingEventAboutToAdd, this, [this](Quotient::RoomEvent *event) { +#endif if (auto roomEvent = eventCast(event)) { if (roomEvent->isThreaded() && roomEvent->threadRootEventId() == m_threadRootId) { addNewEvent(event); @@ -102,7 +106,11 @@ void ThreadModel::fetchMore(const QModelIndex &parent) void ThreadModel::addNewEvent(const Quotient::RoomEvent *event) { const auto room = dynamic_cast(QObject::parent()); - m_contentModels.push_front(new MessageContentModel(room, event->id())); + auto eventId = event->id(); + if (eventId.isEmpty()) { + eventId = event->transactionId(); + } + m_contentModels.push_front(new MessageContentModel(room, eventId)); } void ThreadModel::addModels()