Correct initial state

This commit is contained in:
Benoit Marty 2019-06-03 14:13:56 +02:00
parent c91a409258
commit 4716ceb950
3 changed files with 4 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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)
}