mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 14:38:45 +03:00
Merge pull request #3705 from vector-im/feature/bma/low_dm
Show low priority rooms in dm
This commit is contained in:
commit
f5c79baf63
7 changed files with 121 additions and 86 deletions
1
changelog.d/3463.feature
Normal file
1
changelog.d/3463.feature
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add low priority section in DM tab
|
|
@ -39,12 +39,6 @@ fun spaceSummaryQueryParams(init: (RoomSummaryQueryParams.Builder.() -> Unit) =
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class RoomCategoryFilter {
|
|
||||||
ONLY_DM,
|
|
||||||
ONLY_ROOMS,
|
|
||||||
ALL
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class can be used to filter room summaries to use with:
|
* This class can be used to filter room summaries to use with:
|
||||||
* [org.matrix.android.sdk.api.session.room.Room] and [org.matrix.android.sdk.api.session.room.RoomService]
|
* [org.matrix.android.sdk.api.session.room.Room] and [org.matrix.android.sdk.api.session.room.RoomService]
|
||||||
|
@ -59,11 +53,10 @@ data class RoomSummaryQueryParams(
|
||||||
val excludeType: List<String?>?,
|
val excludeType: List<String?>?,
|
||||||
val includeType: List<String?>?,
|
val includeType: List<String?>?,
|
||||||
val activeSpaceFilter: ActiveSpaceFilter?,
|
val activeSpaceFilter: ActiveSpaceFilter?,
|
||||||
var activeGroupId: String? = null
|
val activeGroupId: String? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
class Builder {
|
class Builder {
|
||||||
|
|
||||||
var roomId: QueryStringValue = QueryStringValue.IsNotEmpty
|
var roomId: QueryStringValue = QueryStringValue.IsNotEmpty
|
||||||
var displayName: QueryStringValue = QueryStringValue.IsNotEmpty
|
var displayName: QueryStringValue = QueryStringValue.IsNotEmpty
|
||||||
var canonicalAlias: QueryStringValue = QueryStringValue.NoCondition
|
var canonicalAlias: QueryStringValue = QueryStringValue.NoCondition
|
||||||
|
|
|
@ -247,10 +247,10 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
|
|
||||||
queryParams.roomCategoryFilter?.let {
|
queryParams.roomCategoryFilter?.let {
|
||||||
when (it) {
|
when (it) {
|
||||||
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
||||||
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
||||||
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
||||||
RoomCategoryFilter.ALL -> {
|
RoomCategoryFilter.ALL -> {
|
||||||
// nop
|
// nop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,15 +274,15 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
query.equalTo(RoomSummaryEntityFields.ROOM_TYPE, it)
|
query.equalTo(RoomSummaryEntityFields.ROOM_TYPE, it)
|
||||||
}
|
}
|
||||||
when (queryParams.roomCategoryFilter) {
|
when (queryParams.roomCategoryFilter) {
|
||||||
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true)
|
||||||
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false)
|
||||||
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0)
|
||||||
RoomCategoryFilter.ALL -> Unit // nop
|
RoomCategoryFilter.ALL -> Unit // nop
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timber.w("VAL: activeSpaceId : ${queryParams.activeSpaceId}")
|
// Timber.w("VAL: activeSpaceId : ${queryParams.activeSpaceId}")
|
||||||
when (queryParams.activeSpaceFilter) {
|
when (queryParams.activeSpaceFilter) {
|
||||||
is ActiveSpaceFilter.ActiveSpace -> {
|
is ActiveSpaceFilter.ActiveSpace -> {
|
||||||
// It's annoying but for now realm java does not support querying in primitive list :/
|
// It's annoying but for now realm java does not support querying in primitive list :/
|
||||||
// https://github.com/realm/realm-java/issues/5361
|
// https://github.com/realm/realm-java/issues/5361
|
||||||
if (queryParams.activeSpaceFilter.currentSpaceId == null) {
|
if (queryParams.activeSpaceFilter.currentSpaceId == null) {
|
||||||
|
@ -300,8 +300,8 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryParams.activeGroupId != null) {
|
queryParams.activeGroupId?.let { activeGroupId ->
|
||||||
query.contains(RoomSummaryEntityFields.GROUP_IDS, queryParams.activeGroupId!!)
|
query.contains(RoomSummaryEntityFields.GROUP_IDS, activeGroupId)
|
||||||
}
|
}
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,4 +20,6 @@ import im.vector.app.features.home.RoomListDisplayMode
|
||||||
|
|
||||||
interface RoomListSectionBuilder {
|
interface RoomListSectionBuilder {
|
||||||
fun buildSections(mode: RoomListDisplayMode) : List<RoomsSection>
|
fun buildSections(mode: RoomListDisplayMode) : List<RoomsSection>
|
||||||
|
|
||||||
|
fun dispose()
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,8 @@ import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.features.home.RoomListDisplayMode
|
import im.vector.app.features.home.RoomListDisplayMode
|
||||||
import im.vector.app.features.invite.AutoAcceptInvites
|
import im.vector.app.features.invite.AutoAcceptInvites
|
||||||
import im.vector.app.features.invite.showInvites
|
import im.vector.app.features.invite.showInvites
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import org.matrix.android.sdk.api.query.RoomCategoryFilter
|
import org.matrix.android.sdk.api.query.RoomCategoryFilter
|
||||||
import org.matrix.android.sdk.api.query.RoomTagQueryFilter
|
import org.matrix.android.sdk.api.query.RoomTagQueryFilter
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
@ -35,16 +34,16 @@ import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.rx.asObservable
|
import org.matrix.android.sdk.rx.asObservable
|
||||||
|
|
||||||
class GroupRoomListSectionBuilder(
|
class RoomListSectionBuilderGroup(
|
||||||
val session: Session,
|
private val session: Session,
|
||||||
val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
val viewModelScope: CoroutineScope,
|
private val appStateHandler: AppStateHandler,
|
||||||
val appStateHandler: AppStateHandler,
|
|
||||||
private val autoAcceptInvites: AutoAcceptInvites,
|
private val autoAcceptInvites: AutoAcceptInvites,
|
||||||
val onDisposable: (Disposable) -> Unit,
|
private val onUpdatable: (UpdatableLivePageResult) -> Unit
|
||||||
val onUdpatable: (UpdatableLivePageResult) -> Unit
|
|
||||||
) : RoomListSectionBuilder {
|
) : RoomListSectionBuilder {
|
||||||
|
|
||||||
|
private val disposables = CompositeDisposable()
|
||||||
|
|
||||||
override fun buildSections(mode: RoomListDisplayMode): List<RoomsSection> {
|
override fun buildSections(mode: RoomListDisplayMode): List<RoomsSection> {
|
||||||
val activeGroupAwareQueries = mutableListOf<UpdatableLivePageResult>()
|
val activeGroupAwareQueries = mutableListOf<UpdatableLivePageResult>()
|
||||||
val sections = mutableListOf<RoomsSection>()
|
val sections = mutableListOf<RoomsSection>()
|
||||||
|
@ -52,7 +51,7 @@ class GroupRoomListSectionBuilder(
|
||||||
|
|
||||||
when (mode) {
|
when (mode) {
|
||||||
RoomListDisplayMode.PEOPLE -> {
|
RoomListDisplayMode.PEOPLE -> {
|
||||||
// 3 sections Invites / Fav / Dms
|
// 4 sections Invites / Fav / Dms / Low Priority
|
||||||
buildPeopleSections(sections, activeGroupAwareQueries, actualGroupId)
|
buildPeopleSections(sections, activeGroupAwareQueries, actualGroupId)
|
||||||
}
|
}
|
||||||
RoomListDisplayMode.ROOMS -> {
|
RoomListDisplayMode.ROOMS -> {
|
||||||
|
@ -69,7 +68,7 @@ class GroupRoomListSectionBuilder(
|
||||||
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
||||||
session.getFilteredPagedRoomSummariesLive(qpm)
|
session.getFilteredPagedRoomSummariesLive(qpm)
|
||||||
.let { updatableFilterLivePageResult ->
|
.let { updatableFilterLivePageResult ->
|
||||||
onUdpatable(updatableFilterLivePageResult)
|
onUpdatable(updatableFilterLivePageResult)
|
||||||
sections.add(RoomsSection(name, updatableFilterLivePageResult.livePagedList))
|
sections.add(RoomsSection(name, updatableFilterLivePageResult.livePagedList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +87,7 @@ class GroupRoomListSectionBuilder(
|
||||||
it.activeGroupId = actualGroupId
|
it.activeGroupId = actualGroupId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(
|
addSection(
|
||||||
sections,
|
sections,
|
||||||
activeGroupAwareQueries,
|
activeGroupAwareQueries,
|
||||||
|
@ -111,8 +111,9 @@ class GroupRoomListSectionBuilder(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.also {
|
}.also {
|
||||||
onDisposable.invoke(it)
|
disposables.add(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections
|
return sections
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +219,19 @@ class GroupRoomListSectionBuilder(
|
||||||
) {
|
) {
|
||||||
it.memberships = listOf(Membership.JOIN)
|
it.memberships = listOf(Membership.JOIN)
|
||||||
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
it.roomTagQueryFilter = RoomTagQueryFilter(false, null, null)
|
it.roomTagQueryFilter = RoomTagQueryFilter(false, false, null)
|
||||||
|
it.activeGroupId = actualGroupId
|
||||||
|
}
|
||||||
|
|
||||||
|
addSection(
|
||||||
|
sections,
|
||||||
|
activeSpaceAwareQueries,
|
||||||
|
R.string.low_priority_header,
|
||||||
|
false
|
||||||
|
) {
|
||||||
|
it.memberships = listOf(Membership.JOIN)
|
||||||
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
|
it.roomTagQueryFilter = RoomTagQueryFilter(false, true, null)
|
||||||
it.activeGroupId = actualGroupId
|
it.activeGroupId = actualGroupId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +244,6 @@ class GroupRoomListSectionBuilder(
|
||||||
withQueryParams(
|
withQueryParams(
|
||||||
{ query.invoke(it) },
|
{ query.invoke(it) },
|
||||||
{ roomQueryParams ->
|
{ roomQueryParams ->
|
||||||
|
|
||||||
val name = stringProvider.getString(nameRes)
|
val name = stringProvider.getString(nameRes)
|
||||||
session.getFilteredPagedRoomSummariesLive(roomQueryParams)
|
session.getFilteredPagedRoomSummariesLive(roomQueryParams)
|
||||||
.also {
|
.also {
|
||||||
|
@ -246,8 +258,9 @@ class GroupRoomListSectionBuilder(
|
||||||
?.notificationCount
|
?.notificationCount
|
||||||
?.postValue(session.getNotificationCountForRooms(roomQueryParams))
|
?.postValue(session.getNotificationCountForRooms(roomQueryParams))
|
||||||
}.also {
|
}.also {
|
||||||
onDisposable.invoke(it)
|
disposables.add(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
sections.add(
|
sections.add(
|
||||||
RoomsSection(
|
RoomsSection(
|
||||||
sectionName = name,
|
sectionName = name,
|
||||||
|
@ -267,4 +280,8 @@ class GroupRoomListSectionBuilder(
|
||||||
.build()
|
.build()
|
||||||
.let { block(it) }
|
.let { block(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
disposables.dispose()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -30,7 +30,7 @@ import im.vector.app.features.invite.AutoAcceptInvites
|
||||||
import im.vector.app.features.invite.showInvites
|
import im.vector.app.features.invite.showInvites
|
||||||
import im.vector.app.space
|
import im.vector.app.space
|
||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxkotlin.Observables
|
import io.reactivex.rxkotlin.Observables
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
@ -46,19 +46,20 @@ import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
|
import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
|
||||||
import org.matrix.android.sdk.rx.asObservable
|
import org.matrix.android.sdk.rx.asObservable
|
||||||
|
|
||||||
class SpaceRoomListSectionBuilder(
|
class RoomListSectionBuilderSpace(
|
||||||
val session: Session,
|
private val session: Session,
|
||||||
val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
val appStateHandler: AppStateHandler,
|
private val appStateHandler: AppStateHandler,
|
||||||
val viewModelScope: CoroutineScope,
|
private val viewModelScope: CoroutineScope,
|
||||||
private val suggestedRoomJoiningState: LiveData<Map<String, Async<Unit>>>,
|
|
||||||
private val autoAcceptInvites: AutoAcceptInvites,
|
private val autoAcceptInvites: AutoAcceptInvites,
|
||||||
val onDisposable: (Disposable) -> Unit,
|
private val onUpdatable: (UpdatableLivePageResult) -> Unit,
|
||||||
val onUdpatable: (UpdatableLivePageResult) -> Unit,
|
private val suggestedRoomJoiningState: LiveData<Map<String, Async<Unit>>>,
|
||||||
val onlyOrphansInHome: Boolean = false
|
private val onlyOrphansInHome: Boolean = false
|
||||||
) : RoomListSectionBuilder {
|
) : RoomListSectionBuilder {
|
||||||
|
|
||||||
val pagedListConfig = PagedList.Config.Builder()
|
private val disposables = CompositeDisposable()
|
||||||
|
|
||||||
|
private val pagedListConfig = PagedList.Config.Builder()
|
||||||
.setPageSize(10)
|
.setPageSize(10)
|
||||||
.setInitialLoadSizeHint(20)
|
.setInitialLoadSizeHint(20)
|
||||||
.setEnablePlaceholders(true)
|
.setEnablePlaceholders(true)
|
||||||
|
@ -70,12 +71,15 @@ class SpaceRoomListSectionBuilder(
|
||||||
val activeSpaceAwareQueries = mutableListOf<RoomListViewModel.ActiveSpaceQueryUpdater>()
|
val activeSpaceAwareQueries = mutableListOf<RoomListViewModel.ActiveSpaceQueryUpdater>()
|
||||||
when (mode) {
|
when (mode) {
|
||||||
RoomListDisplayMode.PEOPLE -> {
|
RoomListDisplayMode.PEOPLE -> {
|
||||||
|
// 4 sections Invites / Fav / Dms / Low Priority
|
||||||
buildDmSections(sections, activeSpaceAwareQueries)
|
buildDmSections(sections, activeSpaceAwareQueries)
|
||||||
}
|
}
|
||||||
RoomListDisplayMode.ROOMS -> {
|
RoomListDisplayMode.ROOMS -> {
|
||||||
|
// 6 sections invites / Fav / Rooms / Low Priority / Server notice / Suggested rooms
|
||||||
buildRoomsSections(sections, activeSpaceAwareQueries)
|
buildRoomsSections(sections, activeSpaceAwareQueries)
|
||||||
}
|
}
|
||||||
RoomListDisplayMode.FILTERED -> {
|
RoomListDisplayMode.FILTERED -> {
|
||||||
|
// Used when searching for rooms
|
||||||
withQueryParams(
|
withQueryParams(
|
||||||
{
|
{
|
||||||
it.memberships = Membership.activeMemberships()
|
it.memberships = Membership.activeMemberships()
|
||||||
|
@ -84,7 +88,7 @@ class SpaceRoomListSectionBuilder(
|
||||||
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
||||||
session.getFilteredPagedRoomSummariesLive(qpm)
|
session.getFilteredPagedRoomSummariesLive(qpm)
|
||||||
.let { updatableFilterLivePageResult ->
|
.let { updatableFilterLivePageResult ->
|
||||||
onUdpatable(updatableFilterLivePageResult)
|
onUpdatable(updatableFilterLivePageResult)
|
||||||
sections.add(RoomsSection(name, updatableFilterLivePageResult.livePagedList))
|
sections.add(RoomsSection(name, updatableFilterLivePageResult.livePagedList))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,13 +138,14 @@ class SpaceRoomListSectionBuilder(
|
||||||
updater.updateForSpaceId(selectedSpace?.roomId)
|
updater.updateForSpaceId(selectedSpace?.roomId)
|
||||||
}
|
}
|
||||||
}.also {
|
}.also {
|
||||||
onDisposable.invoke(it)
|
disposables.add(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections
|
return sections
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildRoomsSections(sections: MutableList<RoomsSection>, activeSpaceAwareQueries: MutableList<RoomListViewModel.ActiveSpaceQueryUpdater>) {
|
private fun buildRoomsSections(sections: MutableList<RoomsSection>,
|
||||||
|
activeSpaceAwareQueries: MutableList<RoomListViewModel.ActiveSpaceQueryUpdater>) {
|
||||||
if (autoAcceptInvites.showInvites()) {
|
if (autoAcceptInvites.showInvites()) {
|
||||||
addSection(
|
addSection(
|
||||||
sections = sections,
|
sections = sections,
|
||||||
|
@ -248,7 +253,7 @@ class SpaceRoomListSectionBuilder(
|
||||||
}.subscribe {
|
}.subscribe {
|
||||||
liveSuggestedRooms.postValue(it)
|
liveSuggestedRooms.postValue(it)
|
||||||
}.also {
|
}.also {
|
||||||
onDisposable.invoke(it)
|
disposables.add(it)
|
||||||
}
|
}
|
||||||
sections.add(
|
sections.add(
|
||||||
RoomsSection(
|
RoomsSection(
|
||||||
|
@ -259,9 +264,11 @@ class SpaceRoomListSectionBuilder(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildDmSections(sections: MutableList<RoomsSection>, activeSpaceAwareQueries: MutableList<RoomListViewModel.ActiveSpaceQueryUpdater>) {
|
private fun buildDmSections(sections: MutableList<RoomsSection>,
|
||||||
|
activeSpaceAwareQueries: MutableList<RoomListViewModel.ActiveSpaceQueryUpdater>) {
|
||||||
if (autoAcceptInvites.showInvites()) {
|
if (autoAcceptInvites.showInvites()) {
|
||||||
addSection(sections = sections,
|
addSection(
|
||||||
|
sections = sections,
|
||||||
activeSpaceUpdaters = activeSpaceAwareQueries,
|
activeSpaceUpdaters = activeSpaceAwareQueries,
|
||||||
nameRes = R.string.invitations_header,
|
nameRes = R.string.invitations_header,
|
||||||
notifyOfLocalEcho = true,
|
notifyOfLocalEcho = true,
|
||||||
|
@ -273,7 +280,8 @@ class SpaceRoomListSectionBuilder(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(sections,
|
addSection(
|
||||||
|
sections,
|
||||||
activeSpaceAwareQueries,
|
activeSpaceAwareQueries,
|
||||||
R.string.bottom_action_favourites,
|
R.string.bottom_action_favourites,
|
||||||
false,
|
false,
|
||||||
|
@ -284,7 +292,8 @@ class SpaceRoomListSectionBuilder(
|
||||||
it.roomTagQueryFilter = RoomTagQueryFilter(true, null, null)
|
it.roomTagQueryFilter = RoomTagQueryFilter(true, null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
addSection(sections,
|
addSection(
|
||||||
|
sections,
|
||||||
activeSpaceAwareQueries,
|
activeSpaceAwareQueries,
|
||||||
R.string.bottom_action_people_x,
|
R.string.bottom_action_people_x,
|
||||||
false,
|
false,
|
||||||
|
@ -292,7 +301,19 @@ class SpaceRoomListSectionBuilder(
|
||||||
) {
|
) {
|
||||||
it.memberships = listOf(Membership.JOIN)
|
it.memberships = listOf(Membership.JOIN)
|
||||||
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
it.roomTagQueryFilter = RoomTagQueryFilter(false, null, null)
|
it.roomTagQueryFilter = RoomTagQueryFilter(false, false, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
addSection(
|
||||||
|
sections,
|
||||||
|
activeSpaceAwareQueries,
|
||||||
|
R.string.low_priority_header,
|
||||||
|
false,
|
||||||
|
RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
|
||||||
|
) {
|
||||||
|
it.memberships = listOf(Membership.JOIN)
|
||||||
|
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
|
||||||
|
it.roomTagQueryFilter = RoomTagQueryFilter(false, true, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +327,6 @@ class SpaceRoomListSectionBuilder(
|
||||||
withQueryParams(
|
withQueryParams(
|
||||||
{ query.invoke(it) },
|
{ query.invoke(it) },
|
||||||
{ roomQueryParams ->
|
{ roomQueryParams ->
|
||||||
|
|
||||||
val name = stringProvider.getString(nameRes)
|
val name = stringProvider.getString(nameRes)
|
||||||
session.getFilteredPagedRoomSummariesLive(
|
session.getFilteredPagedRoomSummariesLive(
|
||||||
roomQueryParams.process(spaceFilterStrategy, appStateHandler.safeActiveSpaceId()),
|
roomQueryParams.process(spaceFilterStrategy, appStateHandler.safeActiveSpaceId()),
|
||||||
|
@ -349,7 +369,6 @@ class SpaceRoomListSectionBuilder(
|
||||||
}
|
}
|
||||||
}.livePagedList
|
}.livePagedList
|
||||||
.let { livePagedList ->
|
.let { livePagedList ->
|
||||||
|
|
||||||
// use it also as a source to update count
|
// use it also as a source to update count
|
||||||
livePagedList.asObservable()
|
livePagedList.asObservable()
|
||||||
.observeOn(Schedulers.computation())
|
.observeOn(Schedulers.computation())
|
||||||
|
@ -366,7 +385,7 @@ class SpaceRoomListSectionBuilder(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}.also {
|
}.also {
|
||||||
onDisposable.invoke(it)
|
disposables.add(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
sections.add(
|
sections.add(
|
||||||
|
@ -410,4 +429,8 @@ class SpaceRoomListSectionBuilder(
|
||||||
RoomListViewModel.SpaceFilterStrategy.NONE -> this
|
RoomListViewModel.SpaceFilterStrategy.NONE -> this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun dispose() {
|
||||||
|
disposables.dispose()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -120,40 +120,34 @@ class RoomListViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val sections: List<RoomsSection> by lazy {
|
private val roomListSectionBuilder = if (appStateHandler.getCurrentRoomGroupingMethod() is RoomGroupingMethod.BySpace) {
|
||||||
if (appStateHandler.getCurrentRoomGroupingMethod() is RoomGroupingMethod.BySpace) {
|
RoomListSectionBuilderSpace(
|
||||||
SpaceRoomListSectionBuilder(
|
session,
|
||||||
session,
|
stringProvider,
|
||||||
stringProvider,
|
appStateHandler,
|
||||||
appStateHandler,
|
viewModelScope,
|
||||||
viewModelScope,
|
autoAcceptInvites,
|
||||||
suggestedRoomJoiningState,
|
{
|
||||||
autoAcceptInvites,
|
updatableQuery = it
|
||||||
{
|
},
|
||||||
it.disposeOnClear()
|
suggestedRoomJoiningState,
|
||||||
},
|
vectorPreferences.labsSpacesOnlyOrphansInHome()
|
||||||
{
|
)
|
||||||
updatableQuery = it
|
} else {
|
||||||
},
|
RoomListSectionBuilderGroup(
|
||||||
vectorPreferences.labsSpacesOnlyOrphansInHome()
|
session,
|
||||||
).buildSections(initialState.displayMode)
|
stringProvider,
|
||||||
} else {
|
appStateHandler,
|
||||||
GroupRoomListSectionBuilder(
|
autoAcceptInvites
|
||||||
session,
|
) {
|
||||||
stringProvider,
|
updatableQuery = it
|
||||||
viewModelScope,
|
|
||||||
appStateHandler,
|
|
||||||
autoAcceptInvites,
|
|
||||||
{
|
|
||||||
it.disposeOnClear()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
updatableQuery = it
|
|
||||||
}
|
|
||||||
).buildSections(initialState.displayMode)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val sections: List<RoomsSection> by lazy {
|
||||||
|
roomListSectionBuilder.buildSections(initialState.displayMode)
|
||||||
|
}
|
||||||
|
|
||||||
override fun handle(action: RoomListAction) {
|
override fun handle(action: RoomListAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is RoomListAction.SelectRoom -> handleSelectRoom(action)
|
is RoomListAction.SelectRoom -> handleSelectRoom(action)
|
||||||
|
@ -341,4 +335,9 @@ class RoomListViewModel @Inject constructor(
|
||||||
_viewEvents.post(value)
|
_viewEvents.post(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCleared() {
|
||||||
|
super.onCleared()
|
||||||
|
roomListSectionBuilder.dispose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue