mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Adds flattenParents field to RoomSummary and corresponding mapping
This commit is contained in:
parent
21fe5a23fb
commit
50839c206b
2 changed files with 16 additions and 13 deletions
|
@ -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 a new issue