aboutsummaryrefslogtreecommitdiff
path: root/lib
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 16:19:33 +0900
commite2b30ad0dc6f5a369cbd1dce3f9c92ef5d801dae (patch)
treec243b4de3c23a0dd47a98fe6fc55b7f9fc8979e2 /lib
parenta28892ca3b40a32556ee7615116c322f6b2a4ae5 (diff)
downloadlibquotient-e2b30ad0dc6f5a369cbd1dce3f9c92ef5d801dae.tar.gz
libquotient-e2b30ad0dc6f5a369cbd1dce3f9c92ef5d801dae.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.
Diffstat (limited to 'lib')
-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();