From 4716ceb95032a6fe6a637d829d196d431260071a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 3 Jun 2019 14:13:56 +0200 Subject: [PATCH] Correct initial state --- .../roompreview/RoomPreviewNoPreviewFragment.kt | 2 -- .../roomdirectory/roompreview/RoomPreviewViewModel.kt | 9 --------- .../roomdirectory/roompreview/RoomPreviewViewState.kt | 5 ++++- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt index 55030df08e..abfd247201 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt @@ -53,8 +53,6 @@ class RoomPreviewNoPreviewFragment : VectorBaseFragment() { super.onActivityCreated(savedInstanceState) bindScope(getOrCreateScope(RoomDirectoryModule.ROOM_DIRECTORY_SCOPE)) setupToolbar(roomPreviewNoPreviewToolbar) - - roomPreviewViewModel.init(roomPreviewData.roomId) } override fun getLayoutResId() = R.layout.fragment_room_preview_no_preview diff --git a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewModel.kt b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewModel.kt index 18ced521ad..131f2719c1 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewModel.kt @@ -70,15 +70,6 @@ class RoomPreviewViewModel(initialState: RoomPreviewViewState, .disposeOnClear() } - // TODO I should not have to do that - fun init(roomId: String) = withState { - setState { - copy( - roomId = roomId - ) - } - } - fun joinRoom() = withState { state -> if (state.roomJoinState == JoinState.JOINING) { // Request already sent, should not happen diff --git a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewState.kt b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewState.kt index 20e23dd0e7..4ba4bdee2f 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewState.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/roomdirectory/roompreview/RoomPreviewViewState.kt @@ -26,4 +26,7 @@ data class RoomPreviewViewState( val roomJoinState: JoinState = JoinState.NOT_JOINED, // Last error of join room request val lastError: Throwable? = null -) : MvRxState \ No newline at end of file +) : MvRxState { + + constructor(args: RoomPreviewData) : this(roomId = args.roomId) +} \ No newline at end of file