mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 14:38:45 +03:00
Fix default encrypted for restricted
+ hide restricted rule if no current space selected
This commit is contained in:
parent
cde6e8cc1b
commit
97dc07f8c9
5 changed files with 30 additions and 9 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
|
|
@ -165,7 +165,11 @@ class CreateRoomController @Inject constructor(
|
||||||
host.stringProvider.getString(R.string.create_room_encryption_description)
|
host.stringProvider.getString(R.string.create_room_encryption_description)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if (viewState.isEncrypted != null) {
|
||||||
switchChecked(viewState.isEncrypted)
|
switchChecked(viewState.isEncrypted)
|
||||||
|
} else {
|
||||||
|
switchChecked(viewState.defaultEncrypted[viewState.roomJoinRules] ?: false)
|
||||||
|
}
|
||||||
|
|
||||||
listener { value ->
|
listener { value ->
|
||||||
host.listener?.setIsEncrypted(value)
|
host.listener?.setIsEncrypted(value)
|
||||||
|
|
|
@ -163,8 +163,9 @@ class CreateRoomFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun selectVisibility() = withState(viewModel) { state ->
|
override fun selectVisibility() = withState(viewModel) { state ->
|
||||||
|
// If restricted is supported and the user is in the context of a parent space
|
||||||
val allowed = if (state.supportsRestricted) {
|
// then show restricted option.
|
||||||
|
val allowed = if (state.supportsRestricted && state.parentSpaceId != null) {
|
||||||
listOf(RoomJoinRules.INVITE, RoomJoinRules.PUBLIC, RoomJoinRules.RESTRICTED)
|
listOf(RoomJoinRules.INVITE, RoomJoinRules.PUBLIC, RoomJoinRules.RESTRICTED)
|
||||||
} else {
|
} else {
|
||||||
listOf(RoomJoinRules.INVITE, RoomJoinRules.PUBLIC)
|
listOf(RoomJoinRules.INVITE, RoomJoinRules.PUBLIC)
|
||||||
|
|
|
@ -109,8 +109,13 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init
|
||||||
|
|
||||||
setState {
|
setState {
|
||||||
copy(
|
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,9 +291,18 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init
|
||||||
disableFederation = state.disableFederation
|
disableFederation = state.disableFederation
|
||||||
|
|
||||||
// Encryption
|
// Encryption
|
||||||
|
// we ignore the isEncrypted for public room as the switch is hidden in this case
|
||||||
|
if (state.roomJoinRules != RoomJoinRules.PUBLIC && state.isEncrypted != null) {
|
||||||
|
// the user explicitly switch the toggle
|
||||||
if (state.isEncrypted) {
|
if (state.isEncrypted) {
|
||||||
enableEncryption()
|
enableEncryption()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// based on default
|
||||||
|
if (state.defaultEncrypted[state.roomJoinRules] == true) {
|
||||||
|
enableEncryption()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should this be non-cancellable?
|
// TODO: Should this be non-cancellable?
|
||||||
|
|
|
@ -28,7 +28,7 @@ data class CreateRoomViewState(
|
||||||
val roomName: String = "",
|
val roomName: String = "",
|
||||||
val roomTopic: String = "",
|
val roomTopic: String = "",
|
||||||
val roomJoinRules: RoomJoinRules = RoomJoinRules.INVITE,
|
val roomJoinRules: RoomJoinRules = RoomJoinRules.INVITE,
|
||||||
val isEncrypted: Boolean = false,
|
val isEncrypted: Boolean? = null,
|
||||||
val showAdvanced: Boolean = false,
|
val showAdvanced: Boolean = false,
|
||||||
val disableFederation: Boolean = false,
|
val disableFederation: Boolean = false,
|
||||||
val homeServerName: String = "",
|
val homeServerName: String = "",
|
||||||
|
@ -38,7 +38,8 @@ data class CreateRoomViewState(
|
||||||
val parentSpaceSummary: RoomSummary? = null,
|
val parentSpaceSummary: RoomSummary? = null,
|
||||||
val supportsRestricted: Boolean = false,
|
val supportsRestricted: Boolean = false,
|
||||||
val aliasLocalPart: String? = null,
|
val aliasLocalPart: String? = null,
|
||||||
val isSubSpace: Boolean = false
|
val isSubSpace: Boolean = false,
|
||||||
|
val defaultEncrypted: Map<RoomJoinRules, Boolean> = emptyMap()
|
||||||
) : MvRxState {
|
) : MvRxState {
|
||||||
|
|
||||||
constructor(args: CreateRoomArgs) : this(
|
constructor(args: CreateRoomArgs) : this(
|
||||||
|
|
Loading…
Reference in a new issue