diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-26 12:00:14 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-26 12:00:38 +0900 |
commit | d1efa846ee2e454b56dc77db403e40f1d9dfc7cd (patch) | |
tree | f61bf11945ed7a055ea9e92bbfd1b816ff78d752 /lib | |
parent | c8becd7ba500802bbb23b986108ad965d4f31df5 (diff) | |
download | libquotient-d1efa846ee2e454b56dc77db403e40f1d9dfc7cd.tar.gz libquotient-d1efa846ee2e454b56dc77db403e40f1d9dfc7cd.zip |
Room::switchVersion(): refuse to switch a version if a tombstone is already there
Closes #306.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 18dacbaa..2930875f 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -836,10 +836,17 @@ void Room::resetHighlightCount() void Room::switchVersion(QString newVersion) { - auto* job = connection()->callApi<UpgradeRoomJob>(id(), newVersion); - connect(job, &BaseJob::failure, this, [this,job] { - emit upgradeFailed(job->errorString()); - }); + if (!successorId().isEmpty()) + { + Q_ASSERT(!successorId().isEmpty()); + emit upgradeFailed(tr("The room is already upgraded")); + } + if (auto* job = connection()->callApi<UpgradeRoomJob>(id(), newVersion)) + connect(job, &BaseJob::failure, this, [this,job] { + emit upgradeFailed(job->errorString()); + }); + else + emit upgradeFailed(tr("Couldn't initiate upgrade")); } bool Room::hasAccountData(const QString& type) const |