From 20d5849e766cd0520932cf8bd042d8d6cf404d06 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Wed, 10 Dec 2025 16:38:58 +0100 Subject: [PATCH] the sec and privacy screen is only displayed if at least one available action can be displayed. --- .../RoomDetailsScreenViewModel.swift | 3 ++- .../Room/RoomPowerLevelProxyProtocol.swift | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift index dc2af074a..afc97636c 100644 --- a/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift +++ b/ElementX/Sources/Screens/RoomDetailsScreen/RoomDetailsScreenViewModel.swift @@ -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) } } diff --git a/ElementX/Sources/Services/Room/RoomPowerLevelProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomPowerLevelProxyProtocol.swift index 0c1cd64f6..100d96cc7 100644 --- a/ElementX/Sources/Services/Room/RoomPowerLevelProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomPowerLevelProxyProtocol.swift @@ -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 + } } }