diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-04-12 10:01:18 +0200 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-04-12 10:01:18 +0200 |
commit | feb5e82fbe96269f1f7683470b02fbc9c70acaa0 (patch) | |
tree | b93ccf9f2d218d8c51c7df721f8e2163c1d07417 /lib | |
parent | 803f5d21935fe159a87864f10a52707eaf93fe5f (diff) | |
download | libquotient-feb5e82fbe96269f1f7683470b02fbc9c70acaa0.tar.gz libquotient-feb5e82fbe96269f1f7683470b02fbc9c70acaa0.zip |
Room::canSwitchVersions(): refactor and make Q_INVOKABLE
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 16 | ||||
-rw-r--r-- | lib/room.h | 6 |
2 files changed, 10 insertions, 12 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 5d4e2141..dc65ebfc 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -758,15 +758,13 @@ bool Room::canSwitchVersions() const if (!successorId().isEmpty()) return false; // No one can upgrade a room that's already upgraded - // TODO, #276: m.room.power_levels - const auto* plEvt = - d->getCurrentState<RoomPowerLevelsEvent>(); - if (!plEvt) - return true; - - const auto currentUserLevel = plEvt->powerLevelForUser(localUser()->id()); - const auto tombstonePowerLevel = plEvt->powerLevelForState("m.room.tombstone"_ls); - return currentUserLevel >= tombstonePowerLevel; + if (const auto* plEvt = d->getCurrentState<RoomPowerLevelsEvent>()) { + const auto currentUserLevel = plEvt->powerLevelForUser(localUser()->id()); + const auto tombstonePowerLevel = + plEvt->powerLevelForState("m.room.tombstone"_ls); + return currentUserLevel >= tombstonePowerLevel; + } + return true; } bool Room::hasUnreadMessages() const { return unreadCount() >= 0; } @@ -474,6 +474,9 @@ public: Q_INVOKABLE bool supportsCalls() const; + /// Whether the current user is allowed to upgrade the room + Q_INVOKABLE bool canSwitchVersions() const; + /// Get a state event with the given event type and state key /*! This method returns a (potentially empty) state event corresponding * to the pair of event type \p evtType and state key \p stateKey. @@ -566,9 +569,6 @@ public slots: /// Mark all messages in the room as read void markAllMessagesAsRead(); - /// Whether the current user is allowed to upgrade the room - bool canSwitchVersions() const; - /// Switch the room's version (aka upgrade) void switchVersion(QString newVersion); |