From 8e08c6108da3751dd0739270cf3435592bb6271b Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 5 Jan 2026 20:01:38 +0100 Subject: [PATCH] feature(security&privacy): make spaceSelection part of the state --- .../impl/root/SecurityAndPrivacyPresenter.kt | 18 +++++++++++------- .../impl/root/SecurityAndPrivacyState.kt | 1 + .../root/SecurityAndPrivacyStateProvider.kt | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt index d9038133e6..c1a7bbeb33 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyPresenter.kt @@ -126,6 +126,12 @@ class SecurityAndPrivacyPresenter( value = (joinedParentSpaces + nonParentJoinedSpaces).toImmutableSet() } + val spaceSelection by remember { + derivedStateOf { + getSpaceSelection(selectableJoinedSpaces, savedSettings.roomAccess) + } + } + var showEnableEncryptionConfirmation by remember(savedSettings.isEncrypted) { mutableStateOf(false) } val permissions by room.permissionsAsState(SecurityAndPrivacyPermissions.DEFAULT) { perms -> perms.securityAndPrivacyPermissions() @@ -183,8 +189,7 @@ class SecurityAndPrivacyPresenter( } SecurityAndPrivacyEvent.ManageAuthorizedSpaces -> navigator.openManageAuthorizedSpaces() SecurityAndPrivacyEvent.SelectSpaceMemberAccess -> handleSpaceMemberAccessSelection( - selectableJoinedSpaces = selectableJoinedSpaces, - savedAccess = savedSettings.roomAccess, + spaceSelection = spaceSelection, editedAccess = editedRoomAccess, ) } @@ -206,6 +211,7 @@ class SecurityAndPrivacyPresenter( permissions = permissions, isSpace = roomInfo.isSpace, selectableJoinedSpaces = selectableJoinedSpaces, + spaceSelection = spaceSelection, eventSink = ::handleEvent, ) @@ -230,15 +236,13 @@ class SecurityAndPrivacyPresenter( } private fun handleSpaceMemberAccessSelection( - selectableJoinedSpaces: Set, - savedAccess: SecurityAndPrivacyRoomAccess, + spaceSelection: SpaceSelection, editedAccess: MutableState, ) { - if(editedAccess.value is SecurityAndPrivacyRoomAccess.SpaceMember) { + if (editedAccess.value is SecurityAndPrivacyRoomAccess.SpaceMember) { return } - val spaceSelection = getSpaceSelection(selectableJoinedSpaces, savedAccess) - when(spaceSelection){ + when (spaceSelection) { is SpaceSelection.None -> Unit is SpaceSelection.Multiple -> navigator.openManageAuthorizedSpaces() is SpaceSelection.Single -> { diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt index b71f375fe7..70a2a72179 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyState.kt @@ -30,6 +30,7 @@ data class SecurityAndPrivacyState( val isSpace: Boolean, private val permissions: SecurityAndPrivacyPermissions, private val selectableJoinedSpaces: ImmutableSet, + private val spaceSelection: SpaceSelection, val eventSink: (SecurityAndPrivacyEvent) -> Unit ) { diff --git a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt index 2c984fd16a..11c4054ac5 100644 --- a/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt +++ b/features/securityandprivacy/impl/src/main/kotlin/io/element/android/features/securityandprivacy/impl/root/SecurityAndPrivacyStateProvider.kt @@ -122,6 +122,7 @@ fun aSecurityAndPrivacyState( isKnockEnabled: Boolean = true, isSpace: Boolean = false, selectableJoinedSpaces: Set = emptySet(), + spaceSelection: SpaceSelection = SpaceSelection.None, eventSink: (SecurityAndPrivacyEvent) -> Unit = {} ) = SecurityAndPrivacyState( editedSettings = editedSettings, @@ -133,5 +134,6 @@ fun aSecurityAndPrivacyState( permissions = permissions, isSpace = isSpace, selectableJoinedSpaces = selectableJoinedSpaces.toImmutableSet(), + spaceSelection = SpaceSelection.None, eventSink = eventSink, )