the sec and privacy screen is only displayed if at least one available action can be displayed.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user