aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-17 18:54:52 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-17 18:54:52 +0900
commitad5d44f31b3ab7e582b84ab05161c97cbc7eefc8 (patch)
tree8fd698b5e14fe6fc026e67a1aac5386fdfab7c1d
parent061c6a69fd55696e7dd82854ace9aa67915628d7 (diff)
downloadlibquotient-ad5d44f31b3ab7e582b84ab05161c97cbc7eefc8.tar.gz
libquotient-ad5d44f31b3ab7e582b84ab05161c97cbc7eefc8.zip
Room: add isUnstable(); unstableVersion() -> stabilityUpdated()
-rw-r--r--lib/room.cpp12
-rw-r--r--lib/room.h8
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);
- }
}
}
diff --git a/lib/room.h b/lib/room.h
index 933a8dd9..197926e7 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -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