Adds flattenParents field to RoomSummary and corresponding mapping
This commit is contained in:
parent
21fe5a23fb
commit
50839c206b
|
@ -62,6 +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 flattenParentIds: List<String> = emptyList(),
|
||||
val roomEncryptionAlgorithm: RoomEncryptionAlgorithm? = null
|
||||
) {
|
||||
|
|
|
@ -194,19 +194,7 @@ internal class RoomSummaryDataSource @Inject constructor(
|
|||
}
|
||||
val dataSourceFactory = realmDataSourceFactory.map {
|
||||
roomSummaryMapper.map(it)
|
||||
}.map { roomSummary ->
|
||||
val parents = roomSummary.flattenParentIds.mapNotNull { parentId ->
|
||||
getRoomSummary(parentId)?.let { parentSummary ->
|
||||
SpaceParentInfo(
|
||||
parentId = parentSummary.flattenParentIds.firstOrNull(),
|
||||
roomSummary = parentSummary,
|
||||
canonical = true,
|
||||
viaServers = emptyList()
|
||||
)
|
||||
}
|
||||
}
|
||||
roomSummary.copy(spaceParents = parents)
|
||||
}
|
||||
}.map { it.getWithParents()}
|
||||
|
||||
val boundaries = MutableLiveData(ResultBoundaries())
|
||||
|
||||
|
@ -245,6 +233,20 @@ 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()
|
||||
)
|
||||
}
|
||||
}
|
||||
return copy(flattenParents = parents)
|
||||
}
|
||||
|
||||
fun getCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> {
|
||||
val liveRooms = monarchy.findAllManagedWithChanges {
|
||||
roomSummariesQuery(it, queryParams)
|
||||
|
|
Loading…
Reference in New Issue