diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 12 | ||||
-rw-r--r-- | lib/room.h | 8 |
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 9c923de7..b13e7873 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -330,6 +330,12 @@ QString Room::version() const return v.isEmpty() ? "1" : v; } +bool Room::isUnstable() const +{ + return !connection()->loadingCapabilities() && + !connection()->stableRoomVersions().contains(version()); +} + QString Room::predecessorId() const { return d->getCurrentState<RoomCreateEvent>()->predecessor().roomId; @@ -1642,15 +1648,15 @@ void Room::checkVersion() const auto defaultVersion = connection()->defaultRoomVersion(); const auto stableVersions = connection()->stableRoomVersions(); Q_ASSERT(!defaultVersion.isEmpty() && successorId().isEmpty()); + // This method is only called after the base state has been loaded + // or the server capabilities have been loaded. + emit stabilityUpdated(defaultVersion, stableVersions); if (!stableVersions.contains(version())) { qCDebug(MAIN) << this << "version is" << version() << "which the server doesn't count as stable"; if (canSwitchVersions()) - { qCDebug(MAIN) << "The current user has enough privileges to fix it"; - emit unstableVersion(defaultVersion, stableVersions); - } } } @@ -81,6 +81,7 @@ namespace QMatrixClient Q_PROPERTY(User* localUser READ localUser CONSTANT) Q_PROPERTY(QString id READ id CONSTANT) Q_PROPERTY(QString version READ version NOTIFY baseStateLoaded) + Q_PROPERTY(bool isUnstable READ isUnstable NOTIFY stabilityUpdated) Q_PROPERTY(QString predecessorId READ predecessorId NOTIFY baseStateLoaded) Q_PROPERTY(QString successorId READ successorId NOTIFY upgraded) Q_PROPERTY(QString name READ name NOTIFY namesChanged) @@ -147,6 +148,7 @@ namespace QMatrixClient User* localUser() const; const QString& id() const; QString version() const; + bool isUnstable() const; QString predecessorId() const; QString successorId() const; QString name() const; @@ -538,9 +540,9 @@ namespace QMatrixClient void callEvent(Room* room, const RoomEvent* event); - /// The room's version is considered unstable; upgrade recommended - void unstableVersion(QString recommendedDefault, - QStringList stableVersions); + /// The room's version stability may have changed + void stabilityUpdated(QString recommendedDefault, + QStringList stableVersions); /// This room has been upgraded and won't receive updates anymore void upgraded(QString serverMessage, Room* successor); /// An attempted room upgrade has failed |