Add room upgrade button

Add button to upgrade the room if the user has a high enough power level and the room is not at the highest available version.
This commit is contained in:
James Graham
2022-12-30 13:51:34 +00:00
parent fa67d174d2
commit 893ee4a763
3 changed files with 65 additions and 0 deletions

View File

@@ -94,6 +94,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
connect(this, &Room::changed, this, [this] {
Q_EMIT canEncryptRoomChanged();
});
connect(connection, &Connection::capabilitiesLoaded, this, &NeoChatRoom::maxRoomVersionChanged);
}
void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
@@ -1370,3 +1371,14 @@ void NeoChatRoom::setCanonicalAlias(const QString &newAlias)
}
});
}
int NeoChatRoom::maxRoomVersion() const
{
int maxVersion = 0;
for (auto roomVersion : connection()->availableRoomVersions()) {
if (roomVersion.id.toInt() > maxVersion) {
maxVersion = roomVersion.id.toInt();
}
}
return maxVersion;
}