mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-15 18:59:12 +03:00
Code review
This commit is contained in:
parent
97dc07f8c9
commit
2605433a3d
3 changed files with 13 additions and 18 deletions
|
@ -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,11 +166,8 @@ class CreateRoomController @Inject constructor(
|
|||
host.stringProvider.getString(R.string.create_room_encryption_description)
|
||||
}
|
||||
)
|
||||
if (viewState.isEncrypted != null) {
|
||||
switchChecked(viewState.isEncrypted)
|
||||
} else {
|
||||
switchChecked(viewState.defaultEncrypted[viewState.roomJoinRules] ?: false)
|
||||
}
|
||||
|
||||
switchChecked(viewState.isEncrypted ?: viewState.defaultEncrypted[viewState.roomJoinRules].orFalse())
|
||||
|
||||
listener { value ->
|
||||
host.listener?.setIsEncrypted(value)
|
||||
|
|
|
@ -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
|
||||
|
@ -291,17 +292,13 @@ class CreateRoomViewModel @AssistedInject constructor(@Assisted private val init
|
|||
disableFederation = state.disableFederation
|
||||
|
||||
// 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) {
|
||||
enableEncryption()
|
||||
}
|
||||
} else {
|
||||
// based on default
|
||||
if (state.defaultEncrypted[state.roomJoinRules] == true) {
|
||||
enableEncryption()
|
||||
}
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ data class CreateRoomViewState(
|
|||
val roomTopic: String = "",
|
||||
val roomJoinRules: RoomJoinRules = RoomJoinRules.INVITE,
|
||||
val isEncrypted: Boolean? = null,
|
||||
val defaultEncrypted: Map<RoomJoinRules, Boolean> = emptyMap(),
|
||||
val showAdvanced: Boolean = false,
|
||||
val disableFederation: Boolean = false,
|
||||
val homeServerName: String = "",
|
||||
|
@ -38,8 +39,7 @@ data class CreateRoomViewState(
|
|||
val parentSpaceSummary: RoomSummary? = null,
|
||||
val supportsRestricted: Boolean = false,
|
||||
val aliasLocalPart: String? = null,
|
||||
val isSubSpace: Boolean = false,
|
||||
val defaultEncrypted: Map<RoomJoinRules, Boolean> = emptyMap()
|
||||
val isSubSpace: Boolean = false
|
||||
) : MvRxState {
|
||||
|
||||
constructor(args: CreateRoomArgs) : this(
|
||||
|
|
Loading…
Add table
Reference in a new issue