Correct initial state
This commit is contained in:
parent
c91a409258
commit
4716ceb950
|
@ -53,8 +53,6 @@ class RoomPreviewNoPreviewFragment : VectorBaseFragment() {
|
||||||
super.onActivityCreated(savedInstanceState)
|
super.onActivityCreated(savedInstanceState)
|
||||||
bindScope(getOrCreateScope(RoomDirectoryModule.ROOM_DIRECTORY_SCOPE))
|
bindScope(getOrCreateScope(RoomDirectoryModule.ROOM_DIRECTORY_SCOPE))
|
||||||
setupToolbar(roomPreviewNoPreviewToolbar)
|
setupToolbar(roomPreviewNoPreviewToolbar)
|
||||||
|
|
||||||
roomPreviewViewModel.init(roomPreviewData.roomId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLayoutResId() = R.layout.fragment_room_preview_no_preview
|
override fun getLayoutResId() = R.layout.fragment_room_preview_no_preview
|
||||||
|
|
|
@ -70,15 +70,6 @@ class RoomPreviewViewModel(initialState: RoomPreviewViewState,
|
||||||
.disposeOnClear()
|
.disposeOnClear()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO I should not have to do that
|
|
||||||
fun init(roomId: String) = withState {
|
|
||||||
setState {
|
|
||||||
copy(
|
|
||||||
roomId = roomId
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun joinRoom() = withState { state ->
|
fun joinRoom() = withState { state ->
|
||||||
if (state.roomJoinState == JoinState.JOINING) {
|
if (state.roomJoinState == JoinState.JOINING) {
|
||||||
// Request already sent, should not happen
|
// Request already sent, should not happen
|
||||||
|
|
|
@ -26,4 +26,7 @@ data class RoomPreviewViewState(
|
||||||
val roomJoinState: JoinState = JoinState.NOT_JOINED,
|
val roomJoinState: JoinState = JoinState.NOT_JOINED,
|
||||||
// Last error of join room request
|
// Last error of join room request
|
||||||
val lastError: Throwable? = null
|
val lastError: Throwable? = null
|
||||||
) : MvRxState
|
) : MvRxState {
|
||||||
|
|
||||||
|
constructor(args: RoomPreviewData) : this(roomId = args.roomId)
|
||||||
|
}
|
Loading…
Reference in New Issue