Compare commits
1 Commits
develop
...
hotfix/1.5
Author | SHA1 | Date |
---|---|---|
ganfra | 0d7b8f0a96 |
|
@ -21,7 +21,6 @@ import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.paging.PagedList
|
import androidx.paging.PagedList
|
||||||
import arrow.core.Option
|
|
||||||
import arrow.core.toOption
|
import arrow.core.toOption
|
||||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
|
@ -88,7 +87,6 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
companion object : MavericksViewModelFactory<HomeRoomListViewModel, HomeRoomListViewState> by hiltMavericksViewModelFactory()
|
companion object : MavericksViewModelFactory<HomeRoomListViewModel, HomeRoomListViewState> by hiltMavericksViewModelFactory()
|
||||||
|
|
||||||
private var roomsFlow: Flow<Option<RoomSummary>>? = null
|
|
||||||
private val pagedListConfig = PagedList.Config.Builder()
|
private val pagedListConfig = PagedList.Config.Builder()
|
||||||
.setPageSize(10)
|
.setPageSize(10)
|
||||||
.setInitialLoadSizeHint(20)
|
.setInitialLoadSizeHint(20)
|
||||||
|
@ -114,6 +112,24 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||||
observeRecents()
|
observeRecents()
|
||||||
observeFilterTabs()
|
observeFilterTabs()
|
||||||
observeRooms()
|
observeRooms()
|
||||||
|
observeSelectedSpace()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun observeSelectedSpace() {
|
||||||
|
spaceStateHandler.getSelectedSpaceFlow()
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.onStart {
|
||||||
|
emit(spaceStateHandler.getCurrentSpace().toOption())
|
||||||
|
}
|
||||||
|
.onEach { selectedSpaceOption ->
|
||||||
|
val liveResults = filteredPagedRoomSummariesLive ?: return@onEach
|
||||||
|
val selectedSpace = selectedSpaceOption.orNull()
|
||||||
|
liveResults.queryParams = liveResults.queryParams.copy(
|
||||||
|
spaceFilter = selectedSpace?.roomId.toActiveSpaceOrNoFilter()
|
||||||
|
)
|
||||||
|
emitEmptyState()
|
||||||
|
}
|
||||||
|
.launchIn(viewModelScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeInvites() {
|
private fun observeInvites() {
|
||||||
|
@ -248,22 +264,6 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||||
).also {
|
).also {
|
||||||
filteredPagedRoomSummariesLive = it
|
filteredPagedRoomSummariesLive = it
|
||||||
}
|
}
|
||||||
|
|
||||||
spaceStateHandler.getSelectedSpaceFlow()
|
|
||||||
.distinctUntilChanged()
|
|
||||||
.onStart {
|
|
||||||
emit(spaceStateHandler.getCurrentSpace().toOption())
|
|
||||||
}
|
|
||||||
.onEach { selectedSpaceOption ->
|
|
||||||
val selectedSpace = selectedSpaceOption.orNull()
|
|
||||||
filteredPagedRoomSummariesLive?.queryParams = liveResults.queryParams.copy(
|
|
||||||
spaceFilter = selectedSpace?.roomId.toActiveSpaceOrNoFilter()
|
|
||||||
)
|
|
||||||
emitEmptyState()
|
|
||||||
}
|
|
||||||
.also { roomsFlow = it }
|
|
||||||
.launchIn(viewModelScope)
|
|
||||||
|
|
||||||
liveResults.livePagedList.observeForever(internalPagedListObserver)
|
liveResults.livePagedList.observeForever(internalPagedListObserver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue