the sec and privacy screen is only displayed if at least one available action can be displayed.

This commit is contained in:
Mauro Romito
2025-12-10 16:38:58 +01:00
committed by Mauro
parent 6dc577623e
commit 20d5849e76
2 changed files with 15 additions and 3 deletions

View File

@@ -292,7 +292,8 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
state.canBanUsers = powerLevels.canOwnUserBan()
state.canJoinCall = powerLevels.canOwnUserJoinCall()
state.canEditRolesOrPermissions = powerLevels.canOwnUserEditRolesAndPermissions()
state.canEditSecurityAndPrivacy = powerLevels.canOwnUserEditSecurityAndPrivacy()
state.canEditSecurityAndPrivacy = powerLevels.canOwnUserEditSecurityAndPrivacy(isSpace: roomInfo.isSpace,
joinRule: roomInfo.joinRule)
}
}

View File

@@ -46,7 +46,18 @@ extension RoomPowerLevelsProxyProtocol {
}
/// Can own user edit any of the security and privacy settings.
func canOwnUserEditSecurityAndPrivacy() -> Bool {
canOwnUser(sendStateEvent: .roomEncryption) || canOwnUser(sendStateEvent: .roomAliases) || canOwnUser(sendStateEvent: .roomJoinRules) || canOwnUser(sendStateEvent: .roomHistoryVisibility)
func canOwnUserEditSecurityAndPrivacy(isSpace: Bool, joinRule: JoinRule?) -> Bool {
let canOwnUserChangeAddress = switch joinRule {
case .knockRestricted, .knock, .public:
canOwnUser(sendStateEvent: .roomAliases)
default:
false
}
return if isSpace {
canOwnUser(sendStateEvent: .roomJoinRules) || canOwnUserChangeAddress
} else {
canOwnUser(sendStateEvent: .roomEncryption) || canOwnUser(sendStateEvent: .roomJoinRules) || canOwnUser(sendStateEvent: .roomHistoryVisibility) || canOwnUserChangeAddress
}
}
}