Cleanup and comment

This commit is contained in:
Benoit Marty 2021-07-19 19:03:41 +02:00
parent 5990e5a52b
commit ac2f1ee7fe
2 changed files with 10 additions and 4 deletions

View file

@ -86,6 +86,7 @@ class RoomListSectionBuilderGroup(
it.activeGroupId = actualGroupId it.activeGroupId = actualGroupId
} }
} }
addSection( addSection(
sections, sections,
activeGroupAwareQueries, activeGroupAwareQueries,
@ -111,6 +112,7 @@ class RoomListSectionBuilderGroup(
}.also { }.also {
onDisposable.invoke(it) onDisposable.invoke(it)
} }
return sections return sections
} }
@ -257,6 +259,7 @@ class RoomListSectionBuilderGroup(
}.also { }.also {
onDisposable.invoke(it) onDisposable.invoke(it)
} }
sections.add( sections.add(
RoomsSection( RoomsSection(
sectionName = name, sectionName = name,

View file

@ -70,12 +70,15 @@ class RoomListSectionBuilderSpace(
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()
@ -140,7 +143,8 @@ class RoomListSectionBuilderSpace(
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,
@ -259,7 +263,8 @@ class RoomListSectionBuilderSpace(
) )
} }
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( addSection(
sections = sections, sections = sections,
@ -321,7 +326,6 @@ class RoomListSectionBuilderSpace(
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()),
@ -364,7 +368,6 @@ class RoomListSectionBuilderSpace(
} }
}.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())