Only gets flattenParents if specifically requested
This commit is contained in:
parent
d12ab17516
commit
a5dc8ec181
|
@ -62,7 +62,7 @@ data class RoomSummary(
|
|||
val roomType: String? = null,
|
||||
val spaceParents: List<SpaceParentInfo>? = null,
|
||||
val spaceChildren: List<SpaceChildInfo>? = null,
|
||||
val flattenParents: List<SpaceParentInfo> = emptyList(),
|
||||
val flattenParents: List<RoomSummary> = emptyList(),
|
||||
val flattenParentIds: List<String> = emptyList(),
|
||||
val roomEncryptionAlgorithm: RoomEncryptionAlgorithm? = null
|
||||
) {
|
||||
|
|
|
@ -127,7 +127,7 @@ internal class DefaultRoomService @Inject constructor(
|
|||
override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
||||
pagedListConfig: PagedList.Config,
|
||||
sortOrder: RoomSortOrder): UpdatableLivePageResult {
|
||||
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
|
||||
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true)
|
||||
}
|
||||
|
||||
override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> {
|
||||
|
|
|
@ -36,7 +36,6 @@ 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.RoomSummary
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomType
|
||||
import org.matrix.android.sdk.api.session.room.model.SpaceParentInfo
|
||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||
import org.matrix.android.sdk.api.session.room.spaceSummaryQueryParams
|
||||
import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
|
||||
|
@ -188,13 +187,14 @@ internal class RoomSummaryDataSource @Inject constructor(
|
|||
|
||||
fun getUpdatablePagedRoomSummariesLive(queryParams: RoomSummaryQueryParams,
|
||||
pagedListConfig: PagedList.Config,
|
||||
sortOrder: RoomSortOrder): UpdatableLivePageResult {
|
||||
sortOrder: RoomSortOrder,
|
||||
getFlattenedParents: Boolean = false): UpdatableLivePageResult {
|
||||
val realmDataSourceFactory = monarchy.createDataSourceFactory { realm ->
|
||||
roomSummariesQuery(realm, queryParams).process(sortOrder)
|
||||
}
|
||||
val dataSourceFactory = realmDataSourceFactory.map {
|
||||
roomSummaryMapper.map(it)
|
||||
}.map { it.getWithParents() }
|
||||
}.map { if (getFlattenedParents) it.getWithParents() else it }
|
||||
|
||||
val boundaries = MutableLiveData(ResultBoundaries())
|
||||
|
||||
|
@ -235,14 +235,7 @@ internal class RoomSummaryDataSource @Inject constructor(
|
|||
|
||||
private fun RoomSummary.getWithParents(): RoomSummary {
|
||||
val parents = flattenParentIds.mapNotNull { parentId ->
|
||||
getRoomSummary(parentId)?.let { parentSummary ->
|
||||
SpaceParentInfo(
|
||||
parentId = parentSummary.flattenParentIds.firstOrNull(),
|
||||
roomSummary = parentSummary,
|
||||
canonical = true,
|
||||
viaServers = emptyList()
|
||||
)
|
||||
}
|
||||
getRoomSummary(parentId)
|
||||
}
|
||||
return copy(flattenParents = parents)
|
||||
}
|
||||
|
|
|
@ -323,9 +323,9 @@ class RoomListSectionBuilderSpace(
|
|||
{
|
||||
it.memberships = Membership.activeMemberships()
|
||||
},
|
||||
{ qpm ->
|
||||
{ queryParams ->
|
||||
val name = stringProvider.getString(R.string.bottom_action_rooms)
|
||||
val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(qpm)
|
||||
val updatableFilterLivePageResult = session.roomService().getFilteredPagedRoomSummariesLive(queryParams)
|
||||
onUpdatable(updatableFilterLivePageResult)
|
||||
|
||||
val itemCountFlow = updatableFilterLivePageResult.livePagedList.asFlow()
|
||||
|
|
Loading…
Reference in New Issue