aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-03-29 13:30:03 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-03-30 15:39:02 +0900
commit3401eee364d9a41f7f28f2702a4b416a11fb19bc (patch)
treec625b6a9e26178c41e6fdcb54527daedfa7d7280
parent460aa0350c22312829d3e2a3d8556221b3f89173 (diff)
downloadlibquotient-3401eee364d9a41f7f28f2702a4b416a11fb19bc.tar.gz
libquotient-3401eee364d9a41f7f28f2702a4b416a11fb19bc.zip
Connection: make sure to mark rooms supposed to be direct chats as such
Closes #305. Relies on correct tracking of Invite membership from the previous commit.
-rw-r--r--lib/connection.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 07c24c92..c09de979 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -609,8 +609,17 @@ CreateRoomJob* Connection::createRoom(RoomVisibility visibility,
: QStringLiteral("private"),
alias, name, topic, invites, invite3pids, roomVersion,
creationContent, initialState, presetName, isDirect);
- connect(job, &BaseJob::success, this, [this,job] {
- emit createdRoom(provideRoom(job->roomId(), JoinState::Join));
+ connect(job, &BaseJob::success, this, [this,job,invites,isDirect] {
+ auto* room = provideRoom(job->roomId(), JoinState::Join);
+ if (!room)
+ {
+ Q_ASSERT_X(room, "Connection::createRoom", "Failed to create a room");
+ return;
+ }
+ emit createdRoom(room);
+ if (isDirect)
+ for (const auto& i: invites)
+ addToDirectChats(room, user(i));
});
return job;
}
@@ -1161,6 +1170,9 @@ Room* Connection::provideRoom(const QString& id, Omittable<JoinState> joinState)
emit leftRoom(room, prevInvite);
if (prevInvite)
{
+ const auto dcUsers = prevInvite->directChatUsers();
+ for (auto* u: dcUsers)
+ addToDirectChats(room, u);
qCDebug(MAIN) << "Deleting Invite state for room" << prevInvite->id();
emit prevInvite->beforeDestruction(prevInvite);
prevInvite->deleteLater();