Skip to content

Commit

Permalink
Add a signal for when a new thread is created in the room which is us…
Browse files Browse the repository at this point in the history
…eful for when an exisiting event is turned into a thread.
  • Loading branch information
nvrWhere committed Jan 2, 2025
1 parent 5d682d9 commit 93ef9a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Quotient/room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Quotient/room.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93ef9a5

Please sign in to comment.