Nicer API

This commit is contained in:
Benoit Marty 2020-01-29 16:26:19 +01:00
parent 8b6ffc2fb1
commit e6c3f7c77b
3 changed files with 9 additions and 3 deletions

View File

@ -125,7 +125,13 @@ data class CreateRoomParams(
* the encryption will be enabled on the created room
*/
@Transient
var enableEncryptionIfInvitedUsersSupportIt: Boolean = false
internal var enableEncryptionIfInvitedUsersSupportIt: Boolean = false
private set
fun enableEncryptionIfInvitedUsersSupportIt(): CreateRoomParams {
enableEncryptionIfInvitedUsersSupportIt = true
return this
}
/**
* Add the crypto algorithm to the room creation parameters.

View File

@ -96,7 +96,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted
invitedUserIds = currentState.selectedUsers.map { it.userId }
)
.setDirectMessage()
.also { it.enableEncryptionIfInvitedUsersSupportIt = true }
.enableEncryptionIfInvitedUsersSupportIt()
session.rx()
.createRoom(roomParams)

View File

@ -131,7 +131,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
invitedUserIds = listOf(otherUserId)
)
.setDirectMessage()
.also { it.enableEncryptionIfInvitedUsersSupportIt = true }
.enableEncryptionIfInvitedUsersSupportIt()
session.createRoom(roomParams, object : MatrixCallback<String> {
override fun onSuccess(data: String) {