mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Merge pull request #4083 from vector-im/feature/bca/spaces_fix_4045
Fix default encrypted for restricted
This commit is contained in:
commit
242b17294d
5 changed files with 23 additions and 7 deletions
1
changelog.d/4045.bugfix
Normal file
1
changelog.d/4045.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Align new room encryption default to Web
|
|
@ -29,6 +29,7 @@ import im.vector.app.features.form.formEditTextItem
|
|||
import im.vector.app.features.form.formEditableAvatarItem
|
||||
import im.vector.app.features.form.formSubmitButtonItem
|
||||
import im.vector.app.features.form.formSwitchItem
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomJoinRules
|
||||
import javax.inject.Inject
|
||||
|
@ -165,7 +166,8 @@ class CreateRoomController @Inject constructor(
|
|||
host.stringProvider.getString(R.string.create_room_encryption_description)
|
||||
}
|
||||
)
|
||||
switchChecked(viewState.isEncrypted)
|
||||
|
||||
switchChecked(viewState.isEncrypted ?: viewState.defaultEncrypted[viewState.roomJoinRules].orFalse())
|
||||
|
||||
listener { value ->
|
||||
host.listener?.setIsEncrypted(value)
|
||||
|
|
|
@ -163,8 +163,9 @@ class CreateRoomFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun selectVisibility() = withState(viewModel) { state ->
|
||||
|
||||
val allowed = if (state.supportsRestricted) {
|
||||
// If restricted is supported and the user is in the context of a parent space
|
||||
// then show restricted option.
|
||||
val allowed = if (state.supportsRestricted && state.parentSpaceId != null) {
|
||||
listOf(RoomJoinRules.INVITE, RoomJoinRules.PUBLIC, RoomJoinRules.RESTRICTED)
|
||||
} else {
|
||||
listOf(RoomJoinRules.INVITE, RoomJoinRules.PUBLIC)
|
||||
|
|
|
@ -36,6 +36,7 @@ import im.vector.app.features.settings.VectorPreferences
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.MatrixPatterns.getDomain
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.raw.RawService
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
@ -109,8 +110,13 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init
|
|||
|
||||
setState {
|
||||
copy(
|
||||
isEncrypted = RoomJoinRules.INVITE == roomJoinRules && adminE2EByDefault,
|
||||
hsAdminHasDisabledE2E = !adminE2EByDefault
|
||||
hsAdminHasDisabledE2E = !adminE2EByDefault,
|
||||
defaultEncrypted = mapOf(
|
||||
RoomJoinRules.INVITE to adminE2EByDefault,
|
||||
RoomJoinRules.PUBLIC to false,
|
||||
RoomJoinRules.RESTRICTED to adminE2EByDefault
|
||||
)
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +292,12 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init
|
|||
disableFederation = state.disableFederation
|
||||
|
||||
// Encryption
|
||||
if (state.isEncrypted) {
|
||||
val shouldEncrypt = when (state.roomJoinRules) {
|
||||
// we ignore the isEncrypted for public room as the switch is hidden in this case
|
||||
RoomJoinRules.PUBLIC -> false
|
||||
else -> state.isEncrypted ?: state.defaultEncrypted[state.roomJoinRules].orFalse()
|
||||
}
|
||||
if (shouldEncrypt) {
|
||||
enableEncryption()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ data class CreateRoomViewState(
|
|||
val roomName: String = "",
|
||||
val roomTopic: String = "",
|
||||
val roomJoinRules: RoomJoinRules = RoomJoinRules.INVITE,
|
||||
val isEncrypted: Boolean = false,
|
||||
val isEncrypted: Boolean? = null,
|
||||
val defaultEncrypted: Map<RoomJoinRules, Boolean> = emptyMap(),
|
||||
val showAdvanced: Boolean = false,
|
||||
val disableFederation: Boolean = false,
|
||||
val homeServerName: String = "",
|
||||
|
|
Loading…
Reference in a new issue