feature(security&privacy): make spaceSelection part of the state

This commit is contained in:
ganfra
2026-01-05 20:01:38 +01:00
parent 2be6b6ce24
commit 8e08c6108d
3 changed files with 14 additions and 7 deletions

View File

@@ -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<SpaceRoom>,
savedAccess: SecurityAndPrivacyRoomAccess,
spaceSelection: SpaceSelection,
editedAccess: MutableState<SecurityAndPrivacyRoomAccess>,
) {
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 -> {

View File

@@ -30,6 +30,7 @@ data class SecurityAndPrivacyState(
val isSpace: Boolean,
private val permissions: SecurityAndPrivacyPermissions,
private val selectableJoinedSpaces: ImmutableSet<SpaceRoom>,
private val spaceSelection: SpaceSelection,
val eventSink: (SecurityAndPrivacyEvent) -> Unit
) {

View File

@@ -122,6 +122,7 @@ fun aSecurityAndPrivacyState(
isKnockEnabled: Boolean = true,
isSpace: Boolean = false,
selectableJoinedSpaces: Set<SpaceRoom> = 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,
)