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/room.cpp | |
parent | 803f5d21935fe159a87864f10a52707eaf93fe5f (diff) | |
download | libquotient-feb5e82fbe96269f1f7683470b02fbc9c70acaa0.tar.gz libquotient-feb5e82fbe96269f1f7683470b02fbc9c70acaa0.zip |
Room::canSwitchVersions(): refactor and make Q_INVOKABLE
Diffstat (limited to 'lib/room.cpp')
-rw-r--r-- | lib/room.cpp | 16 |
1 files changed, 7 insertions, 9 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; } |