Use the libQuotient function to get the user power level as it is now equivalent
This commit is contained in:
@@ -174,8 +174,8 @@ void UserListModel::refreshAllMembers()
|
||||
m_members = m_currentRoom->joinedMemberIds();
|
||||
MemberSorter sorter;
|
||||
std::sort(m_members.begin(), m_members.end(), [&sorter, this](const auto &left, const auto &right) {
|
||||
const auto leftPl = m_currentRoom->getUserPowerLevel(left);
|
||||
const auto rightPl = m_currentRoom->getUserPowerLevel(right);
|
||||
const auto leftPl = m_currentRoom->memberEffectivePowerLevel(left);
|
||||
const auto rightPl = m_currentRoom->memberEffectivePowerLevel(right);
|
||||
if (leftPl > rightPl) {
|
||||
return true;
|
||||
} else if (rightPl > leftPl) {
|
||||
@@ -184,7 +184,6 @@ void UserListModel::refreshAllMembers()
|
||||
|
||||
return sorter(m_currentRoom->member(left), m_currentRoom->member(right));
|
||||
});
|
||||
|
||||
}
|
||||
endResetModel();
|
||||
Q_EMIT usersRefreshed();
|
||||
|
||||
@@ -784,22 +784,6 @@ void NeoChatRoom::setUserPowerLevel(const QString &userID, const int &powerLevel
|
||||
}
|
||||
}
|
||||
|
||||
int NeoChatRoom::getUserPowerLevel(const QString &userId) const
|
||||
{
|
||||
if (!successorId().isEmpty()) {
|
||||
return 0; // No one can upgrade a room that's already upgraded
|
||||
}
|
||||
|
||||
const auto &mId = userId.isEmpty() ? connection()->userId() : userId;
|
||||
if (const auto *plEvent = currentState().get<RoomPowerLevelsEvent>()) {
|
||||
return plEvent->powerLevelForUser(mId);
|
||||
}
|
||||
if (const auto *createEvent = creation()) {
|
||||
return createEvent->senderId() == mId ? 100 : 0;
|
||||
}
|
||||
return 0; // That's rather weird but may happen, according to rvdh
|
||||
}
|
||||
|
||||
QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user, QString reason)
|
||||
{
|
||||
QStringList events;
|
||||
|
||||
@@ -503,14 +503,6 @@ public:
|
||||
|
||||
bool canEncryptRoom() const;
|
||||
|
||||
/**
|
||||
* @brief Get the power level for the given user ID in the room.
|
||||
*
|
||||
* Returns the default value for a user in the room if they have no escalated
|
||||
* privileges or if they are not a member so membership should be known before using.
|
||||
*/
|
||||
Q_INVOKABLE [[nodiscard]] int getUserPowerLevel(const QString &userId) const;
|
||||
|
||||
Q_INVOKABLE void setUserPowerLevel(const QString &userID, const int &powerLevel);
|
||||
|
||||
ChatBarCache *mainCache() const;
|
||||
|
||||
@@ -118,7 +118,7 @@ Kirigami.Dialog {
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("kick") && room.containsUser(root.user.id) && room.getUserPowerLevel(root.user.id) < room.getUserPowerLevel(root.connection.localUserId)
|
||||
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("kick") && room.containsUser(root.user.id) && room.memberEffectivePowerLevel(root.user.id) < room.memberEffectivePowerLevel(root.connection.localUserId)
|
||||
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Kick this user")
|
||||
@@ -156,7 +156,7 @@ Kirigami.Dialog {
|
||||
}
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("ban") && !room.isUserBanned(root.user.id) && room.getUserPowerLevel(root.user.id) < room.getUserPowerLevel(root.connection.localUserId)
|
||||
visible: root.room && root.user.id !== root.connection.localUserId && room.canSendState("ban") && !room.isUserBanned(root.user.id) && room.memberEffectivePowerLevel(root.user.id) < room.memberEffectivePowerLevel(root.connection.localUserId)
|
||||
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Ban this user")
|
||||
@@ -203,7 +203,7 @@ Kirigami.Dialog {
|
||||
let dialog = powerLevelDialog.createObject(this, {
|
||||
room: root.room,
|
||||
userId: root.user.id,
|
||||
powerLevel: root.room.getUserPowerLevel(root.user.id)
|
||||
powerLevel: root.room.memberEffectivePowerLevel(root.user.id)
|
||||
});
|
||||
dialog.open();
|
||||
root.close();
|
||||
|
||||
@@ -57,7 +57,7 @@ FormCard.FormCardPage {
|
||||
QQC2.Label {
|
||||
id: powerLevelLabel
|
||||
text: privilegedUserDelegate.powerLevelString
|
||||
visible: !room.canSendState("m.room.power_levels") || (room.getUserPowerLevel(room.localMember.id) <= privilegedUserDelegate.powerLevel && privilegedUserDelegate.userId != room.localMember.id)
|
||||
visible: !room.canSendState("m.room.power_levels") || (room.memberEffectivePowerLevel(room.localMember.id) <= privilegedUserDelegate.powerLevel && privilegedUserDelegate.userId != room.localMember.id)
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
}
|
||||
QQC2.ComboBox {
|
||||
|
||||
Reference in New Issue
Block a user