aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-17 17:46:26 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-17 17:46:26 +0900
commit061c6a69fd55696e7dd82854ace9aa67915628d7 (patch)
tree20decf874e4df1cdb8674b5c2ef283fce2115e08 /lib
parentac5daf2ed495a932aba23606f5b3d0dca5aaf676 (diff)
downloadlibquotient-061c6a69fd55696e7dd82854ace9aa67915628d7.tar.gz
libquotient-061c6a69fd55696e7dd82854ace9aa67915628d7.zip
Room: emit room, not id in upgraded(); add upgradeFailed()
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp19
-rw-r--r--lib/room.h4
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;
}
);
diff --git a/lib/room.h b/lib/room.h
index f12627f3..933a8dd9 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -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*);