Fix room name reset issue when rotating the screen

This commit is contained in:
Benoit Marty 2020-10-20 16:57:10 +02:00 committed by Benoit Marty
parent dc8668b222
commit 613573931e

View file

@ -20,6 +20,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import com.airbnb.mvrx.viewModel import com.airbnb.mvrx.viewModel
import com.airbnb.mvrx.withState
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.ScreenComponent import im.vector.app.core.di.ScreenComponent
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
@ -58,19 +59,19 @@ class RoomDirectoryActivity : VectorBaseActivity() {
.subscribe { sharedAction -> .subscribe { sharedAction ->
when (sharedAction) { when (sharedAction) {
is RoomDirectorySharedAction.Back -> onBackPressed() is RoomDirectorySharedAction.Back -> onBackPressed()
is RoomDirectorySharedAction.CreateRoom -> is RoomDirectorySharedAction.CreateRoom -> {
addFragmentToBackstack(R.id.simpleFragmentContainer, CreateRoomFragment::class.java) addFragmentToBackstack(R.id.simpleFragmentContainer, CreateRoomFragment::class.java)
// Transmit the filter to the createRoomViewModel
withState(roomDirectoryViewModel) {
createRoomViewModel.handle(CreateRoomAction.SetName(it.currentFilter))
}
}
is RoomDirectorySharedAction.ChangeProtocol -> is RoomDirectorySharedAction.ChangeProtocol ->
addFragmentToBackstack(R.id.simpleFragmentContainer, RoomDirectoryPickerFragment::class.java) addFragmentToBackstack(R.id.simpleFragmentContainer, RoomDirectoryPickerFragment::class.java)
is RoomDirectorySharedAction.Close -> finish() is RoomDirectorySharedAction.Close -> finish()
} }
} }
.disposeOnDestroy() .disposeOnDestroy()
roomDirectoryViewModel.selectSubscribe(this, PublicRoomsViewState::currentFilter) { currentFilter ->
// Transmit the filter to the createRoomViewModel
createRoomViewModel.handle(CreateRoomAction.SetName(currentFilter))
}
} }
override fun initUiAndData() { override fun initUiAndData() {