From d1efa846ee2e454b56dc77db403e40f1d9dfc7cd Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 26 Mar 2019 12:00:14 +0900 Subject: Room::switchVersion(): refuse to switch a version if a tombstone is already there Closes #306. --- lib/room.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lib') 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(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(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 -- cgit v1.2.3