From 93ef9a57b13ac7c31f1bb47d63ef677aed41c6bf Mon Sep 17 00:00:00 2001 From: James Graham Date: Thu, 2 Jan 2025 10:58:54 +0000 Subject: [PATCH 1/2] Add a signal for when a new thread is created in the room which is useful for when an exisiting event is turned into a thread. --- Quotient/room.cpp | 4 ++++ Quotient/room.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/Quotient/room.cpp b/Quotient/room.cpp index 88c5ffa19..6d6503de0 100644 --- a/Quotient/room.cpp +++ b/Quotient/room.cpp @@ -1776,8 +1776,10 @@ void Room::Private::updateThread(const RoomEvent* event) return; } + auto isNew = false; auto& thread = threads[rme->threadRootEventId()]; if (thread.threadRootId.isEmpty()) { + isNew = true; thread.threadRootId = rme->threadRootEventId(); // If we can't find the root we assume it's a historical event and will be loaded later. if (auto rootIt = q->findInTimeline(thread.threadRootId); rootIt != historyEdge()) { @@ -1798,6 +1800,8 @@ void Room::Private::updateThread(const RoomEvent* event) thread.addEvent(rme, (threadLatestIndex == eventsIndex.cend() || *eventIndexIt > *threadLatestIndex), rme->senderId() == connection->userId()); + + if (isNew) { emit q->newThread(thread); } } const Avatar& Room::memberAvatarObject(const QString& memberId) const diff --git a/Quotient/room.h b/Quotient/room.h index a0f900b35..f4941db58 100644 --- a/Quotient/room.h +++ b/Quotient/room.h @@ -870,6 +870,9 @@ public Q_SLOTS: */ void messageSent(QString txnId, QString eventId); + //! A new thread has been created/added in the room + void newThread(const Thread& newThread); + /** A common signal for various kinds of changes in the room * Aside from all changes in the room state * @param changes a set of flags describing what changes occurred From e1f35acfc13acc57d660c026f0df3bc2876a1a66 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sat, 11 Jan 2025 11:14:25 +0000 Subject: [PATCH 2/2] Comment update --- Quotient/room.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Quotient/room.cpp b/Quotient/room.cpp index 6d6503de0..5a8ca167d 100644 --- a/Quotient/room.cpp +++ b/Quotient/room.cpp @@ -1776,10 +1776,9 @@ void Room::Private::updateThread(const RoomEvent* event) return; } - auto isNew = false; auto& thread = threads[rme->threadRootEventId()]; + const auto isNew = thread.threadRpotId.isEmpty(); if (thread.threadRootId.isEmpty()) { - isNew = true; thread.threadRootId = rme->threadRootEventId(); // If we can't find the root we assume it's a historical event and will be loaded later. if (auto rootIt = q->findInTimeline(thread.threadRootId); rootIt != historyEdge()) {