Cleanup the ViewModels

This commit is contained in:
Benoit Marty 2021-11-22 16:45:18 +01:00
parent e10af6476f
commit aee34ad552
3 changed files with 17 additions and 28 deletions

View file

@ -25,7 +25,6 @@ import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.settings.VectorDataStore
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
class DebugPrivateSettingsViewModel @AssistedInject constructor(
@ -45,12 +44,10 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
}
private fun observeVectorDataStore() {
vectorDataStore.forceDialPadDisplayFlow.onEach {
setState {
copy(
dialPadVisible = it
)
}
vectorDataStore.forceDialPadDisplayFlow.setOnEach {
copy(
dialPadVisible = it
)
}
}

View file

@ -38,7 +38,6 @@ import im.vector.app.features.invite.showInvites
import im.vector.app.features.settings.VectorDataStore
import im.vector.app.features.ui.UiStateRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.flatMapLatest
@ -104,19 +103,16 @@ class HomeDetailViewModel @AssistedInject constructor(
private var forceDialPad = false
private fun observeDataStore() {
viewModelScope.launch {
vectorDataStore.pushCounterFlow.collect { nbOfPush ->
setState {
copy(
pushCounter = nbOfPush
)
}
}
vectorDataStore.forceDialPadDisplayFlow.collect { force ->
forceDialPad = force
updateShowDialPadTab()
}
vectorDataStore.pushCounterFlow.setOnEach { nbOfPush ->
copy(
pushCounter = nbOfPush
)
}
vectorDataStore.forceDialPadDisplayFlow.onEach { force ->
forceDialPad = force
updateShowDialPadTab()
}.launchIn(viewModelScope)
}
override fun handle(action: HomeDetailAction) {

View file

@ -195,14 +195,10 @@ class RoomDetailViewModel @AssistedInject constructor(
}
private fun observeDataStore() {
viewModelScope.launch {
vectorDataStore.pushCounterFlow.collect { nbOfPush ->
setState {
copy(
pushCounter = nbOfPush
)
}
}
vectorDataStore.pushCounterFlow.setOnEach { nbOfPush ->
copy(
pushCounter = nbOfPush
)
}
}