mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Merge remote-tracking branch 'origin/feature/nfe/app_layout_hide_filters_for_space' into feature/eric/new-layout-labs
This commit is contained in:
commit
91b4918526
1 changed files with 31 additions and 16 deletions
|
@ -40,6 +40,7 @@ import kotlinx.coroutines.flow.asSharedFlow
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
|
import kotlinx.coroutines.flow.flatMapLatest
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
@ -202,24 +203,38 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||||
private fun getFiltersDataFlow(): SharedFlow<Optional<List<HomeRoomFilter>>> {
|
private fun getFiltersDataFlow(): SharedFlow<Optional<List<HomeRoomFilter>>> {
|
||||||
val flow = MutableSharedFlow<Optional<List<HomeRoomFilter>>>(replay = 1)
|
val flow = MutableSharedFlow<Optional<List<HomeRoomFilter>>>(replay = 1)
|
||||||
|
|
||||||
val favouritesFlow = session.flow()
|
val spaceFLow = spaceStateHandler.getSelectedSpaceFlow()
|
||||||
.liveRoomSummaries(
|
|
||||||
RoomSummaryQueryParams.Builder().also { builder ->
|
|
||||||
builder.roomTagQueryFilter = RoomTagQueryFilter(true, null, null)
|
|
||||||
}.build()
|
|
||||||
)
|
|
||||||
.map { it.isNotEmpty() }
|
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
|
.onStart {
|
||||||
|
emit(spaceStateHandler.getCurrentSpace().toOption())
|
||||||
|
}
|
||||||
|
|
||||||
val dmsFLow = session.flow()
|
val favouritesFlow =
|
||||||
.liveRoomSummaries(
|
spaceFLow.flatMapLatest { selectedSpace ->
|
||||||
RoomSummaryQueryParams.Builder().also { builder ->
|
session.flow()
|
||||||
builder.memberships = listOf(Membership.JOIN)
|
.liveRoomSummaries(
|
||||||
builder.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
RoomSummaryQueryParams.Builder().also { builder ->
|
||||||
}.build()
|
builder.spaceFilter = selectedSpace.orNull()?.roomId.toActiveSpaceOrNoFilter()
|
||||||
)
|
builder.roomTagQueryFilter = RoomTagQueryFilter(true, null, null)
|
||||||
.map { it.isNotEmpty() }
|
}.build()
|
||||||
.distinctUntilChanged()
|
)
|
||||||
|
}
|
||||||
|
.map { it.isNotEmpty() }
|
||||||
|
.distinctUntilChanged()
|
||||||
|
|
||||||
|
val dmsFLow =
|
||||||
|
spaceFLow.flatMapLatest { selectedSpace ->
|
||||||
|
session.flow()
|
||||||
|
.liveRoomSummaries(
|
||||||
|
RoomSummaryQueryParams.Builder().also { builder ->
|
||||||
|
builder.spaceFilter = selectedSpace.orNull()?.roomId.toActiveSpaceOrNoFilter()
|
||||||
|
builder.memberships = listOf(Membership.JOIN)
|
||||||
|
builder.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
|
}.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.map { it.isNotEmpty() }
|
||||||
|
.distinctUntilChanged()
|
||||||
|
|
||||||
combine(favouritesFlow, dmsFLow, preferencesStore.areFiltersEnabledFlow) { hasFavourite, hasDm, areFiltersEnabled ->
|
combine(favouritesFlow, dmsFLow, preferencesStore.areFiltersEnabledFlow) { hasFavourite, hasDm, areFiltersEnabled ->
|
||||||
Triple(hasFavourite, hasDm, areFiltersEnabled)
|
Triple(hasFavourite, hasDm, areFiltersEnabled)
|
||||||
|
|
Loading…
Reference in a new issue