mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 19:05:56 +03:00
review fixes
This commit is contained in:
parent
602b378b65
commit
d8060a7922
3 changed files with 9 additions and 7 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.home.room.list.home
|
||||
|
||||
import androidx.paging.PagedList
|
||||
import com.airbnb.epoxy.EpoxyModel
|
||||
import com.airbnb.epoxy.paging.PagedListEpoxyController
|
||||
import im.vector.app.core.platform.StateView
|
||||
|
@ -75,6 +76,13 @@ class HomeFilteredRoomsController @Inject constructor(
|
|||
this.emptyStateData = state
|
||||
}
|
||||
|
||||
fun submitPagedList(newList: PagedList<RoomSummary>) {
|
||||
submitList(newList)
|
||||
if (newList.isEmpty()) {
|
||||
requestForcedModelBuild()
|
||||
}
|
||||
}
|
||||
|
||||
override fun buildItemModel(currentPosition: Int, item: RoomSummary?): EpoxyModel<*> {
|
||||
return if (item == null) {
|
||||
val host = this
|
||||
|
|
|
@ -154,7 +154,7 @@ class HomeRoomListFragment :
|
|||
|
||||
roomListViewModel.onEach(HomeRoomListViewState::roomsPagedList) { roomsList ->
|
||||
roomsList?.let {
|
||||
roomsController.submitList(it)
|
||||
roomsController.submitPagedList(it)
|
||||
if (it.isEmpty()) {
|
||||
roomsController.requestForcedModelBuild()
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package im.vector.app.features.home.room.list.home
|
|||
import android.widget.ImageView
|
||||
import androidx.lifecycle.asFlow
|
||||
import androidx.paging.PagedList
|
||||
import arrow.core.Option
|
||||
import arrow.core.toOption
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import dagger.assisted.Assisted
|
||||
|
@ -37,7 +36,6 @@ import im.vector.app.features.displayname.getBestName
|
|||
import im.vector.app.features.home.room.list.home.header.HomeRoomFilter
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
|
@ -46,7 +44,6 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
|||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
@ -90,7 +87,6 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
|||
|
||||
companion object : MavericksViewModelFactory<HomeRoomListViewModel, HomeRoomListViewState> by hiltMavericksViewModelFactory()
|
||||
|
||||
private var roomsFlow: Flow<Option<RoomSummary>>? = null
|
||||
private val pagedListConfig = PagedList.Config.Builder()
|
||||
.setPageSize(10)
|
||||
.setInitialLoadSizeHint(20)
|
||||
|
@ -258,7 +254,6 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
|||
)
|
||||
emitEmptyState()
|
||||
}
|
||||
.also { roomsFlow = it }
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
roomsFlowJob?.cancel(CancellationException())
|
||||
|
@ -268,7 +263,6 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
|||
.onEach {
|
||||
setState { copy(roomsPagedList = it) }
|
||||
}
|
||||
.flowOn(Dispatchers.Default)
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue