mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
Room settings: use boolean instead of Async
This commit is contained in:
parent
28db05e509
commit
d672313649
3 changed files with 5 additions and 6 deletions
|
@ -20,7 +20,6 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
|
@ -82,7 +81,7 @@ class RoomSettingsFragment @Inject constructor(
|
|||
}
|
||||
|
||||
private fun renderRoomSummary(state: RoomSettingsViewState) {
|
||||
waiting_view.isVisible = state.currentRequest is Loading
|
||||
waiting_view.isVisible = state.isLoading
|
||||
|
||||
state.roomSummary()?.let {
|
||||
roomSettingsToolbarTitleView.text = it.displayName
|
||||
|
|
|
@ -71,13 +71,13 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
|
||||
private fun handleEnableEncryption() {
|
||||
setState {
|
||||
copy(currentRequest = Loading())
|
||||
copy(isLoading = true)
|
||||
}
|
||||
|
||||
room.enableEncryption(MXCRYPTO_ALGORITHM_MEGOLM, object : MatrixCallback<Unit> {
|
||||
override fun onFailure(failure: Throwable) {
|
||||
setState {
|
||||
copy(currentRequest = Uninitialized)
|
||||
copy(isLoading = false)
|
||||
}
|
||||
|
||||
_requestErrorLiveData.postLiveEvent(failure)
|
||||
|
@ -85,7 +85,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
|
||||
override fun onSuccess(data: Unit) {
|
||||
setState {
|
||||
copy(currentRequest = Uninitialized)
|
||||
copy(isLoading = false)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -25,7 +25,7 @@ import im.vector.riotx.features.roomprofile.RoomProfileArgs
|
|||
data class RoomSettingsViewState(
|
||||
val roomId: String,
|
||||
val roomSummary: Async<RoomSummary> = Uninitialized,
|
||||
val currentRequest: Async<Unit> = Uninitialized
|
||||
val isLoading: Boolean = false
|
||||
) : MvRxState {
|
||||
|
||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||
|
|
Loading…
Reference in a new issue