diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 19 | ||||
-rw-r--r-- | lib/room.h | 4 |
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 14e60f51..9c923de7 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -815,7 +815,10 @@ void Room::resetHighlightCount() void Room::switchVersion(QString newVersion) { - connection()->callApi<UpgradeRoomJob>(id(), newVersion); + auto* job = connection()->callApi<UpgradeRoomJob>(id(), newVersion); + connect(job, &BaseJob::failure, this, [this,job] { + emit upgradeFailed(job->errorString()); + }); } bool Room::hasAccountData(const QString& type) const @@ -2205,7 +2208,19 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) return OtherChange; } , [this] (const RoomTombstoneEvent& evt) { - emit upgraded(evt.serverMessage(), evt.successorRoomId()); + const auto newRoomId = evt.successorRoomId(); + if (auto* newRoom = connection()->room(newRoomId)) + emit upgraded(evt.serverMessage(), newRoom); + else + connectUntil(connection(), &Connection::loadedRoomState, this, + [this,newRoomId,serverMsg=evt.serverMessage()] + (Room* newRoom) { + if (newRoom->id() != newRoomId) + return false; + emit upgraded(serverMsg, newRoom); + return true; + }); + return OtherChange; } ); @@ -542,7 +542,9 @@ namespace QMatrixClient void unstableVersion(QString recommendedDefault, QStringList stableVersions); /// This room has been upgraded and won't receive updates anymore - void upgraded(QString serverMessage, QString successorId); + void upgraded(QString serverMessage, Room* successor); + /// An attempted room upgrade has failed + void upgradeFailed(QString errorMessage); /// The room is about to be deleted void beforeDestruction(Room*); |