diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-25 13:21:44 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-25 13:28:57 +0900 |
commit | 6ab89ce02e450605cebd432d2113a3115d0cf8c1 (patch) | |
tree | b336b756db36d53a2a8df8af3c350133de375289 | |
parent | b4e699a0076fc7827fa89af33d8774d43eb017ce (diff) | |
download | libquotient-6ab89ce02e450605cebd432d2113a3115d0cf8c1.tar.gz libquotient-6ab89ce02e450605cebd432d2113a3115d0cf8c1.zip |
Connection::forgetRoom: Support forgetting invites too
Closes #157.
-rw-r--r-- | connection.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/connection.cpp b/connection.cpp index f498f613..e182f9d9 100644 --- a/connection.cpp +++ b/connection.cpp @@ -377,17 +377,19 @@ ForgetRoomJob* Connection::forgetRoom(const QString& id) // a ForgetRoomJob is created in advance and can be returned in a probably // not-yet-started state (it will start once /leave completes). auto forgetJob = new ForgetRoomJob(id); - auto joinedRoom = d->roomMap.value({id, false}); - if (joinedRoom && joinedRoom->joinState() == JoinState::Join) + auto room = d->roomMap.value({id, false}); + if (!room) + room = d->roomMap.value({id, true}); + if (room && room->joinState() != JoinState::Leave) { - auto leaveJob = joinedRoom->leaveRoom(); + auto leaveJob = room->leaveRoom(); connect(leaveJob, &BaseJob::success, this, [this, forgetJob] { forgetJob->start(connectionData()); }); connect(leaveJob, &BaseJob::failure, forgetJob, &BaseJob::abandon); } else forgetJob->start(connectionData()); - connect(forgetJob, &BaseJob::success, this, [this, &id] + connect(forgetJob, &BaseJob::success, this, [this, id] { // If the room happens to be in the map (possible in both forms), // delete the found object(s). |