Changes directParentName to a list

This commit is contained in:
ericdecanini 2022-07-01 13:34:55 +01:00
parent cb400b660d
commit ed3a201f0b
5 changed files with 6 additions and 15 deletions

View File

@ -164,9 +164,9 @@ data class RoomSummary(
*/
val spaceChildren: List<SpaceChildInfo>? = null,
/**
* The name of the room's direct space parent if any.
* The names of the room's direct space parents if any.
*/
val directParentName: String? = null,
val directParentNames: List<String> = emptyList(),
/**
* List of all the space parent Ids.
*/

View File

@ -106,7 +106,7 @@ internal class RoomSummaryMapper @Inject constructor(
worldReadable = it.childSummaryEntity?.joinRules == RoomJoinRules.PUBLIC
)
},
directParentName = roomSummaryEntity.directParentName,
directParentNames = roomSummaryEntity.directParentNames.toList(),
flattenParentIds = roomSummaryEntity.flattenParentIds?.split("|") ?: emptyList(),
roomEncryptionAlgorithm = when (val alg = roomSummaryEntity.e2eAlgorithm) {
// I should probably use #hasEncryptorClassForAlgorithm but it says it supports

View File

@ -235,10 +235,7 @@ internal open class RoomSummaryEntity(
if (value != field) field = value
}
var directParentName: String? = null
set(value) {
if (value != field) field = value
}
var directParentNames: RealmList<String> = RealmList()
var flattenParentIds: String? = null
set(value) {

View File

@ -351,15 +351,9 @@ internal class RoomSummaryUpdater @Inject constructor(
}
val acyclicGraph = graph.withoutEdges(backEdges)
// Timber.v("## SPACES: acyclicGraph $acyclicGraph")
val flattenSpaceParents = acyclicGraph.flattenDestination().map {
it.key.name to it.value.map { it.name }
}.toMap()
// Timber.v("## SPACES: flattenSpaceParents ${flattenSpaceParents.map { it.key.name to it.value.map { it.name } }.joinToString("\n") {
// it.first + ": [" + it.second.joinToString(",") + "]"
// }}")
// Timber.v("## SPACES: lookup map ${lookupMap.map { it.key.name to it.value.map { it.name } }.toMap()}")
lookupMap.entries
.filter { it.key.roomType == RoomType.SPACE && it.key.membership == Membership.JOIN }
@ -370,7 +364,7 @@ internal class RoomSummaryUpdater @Inject constructor(
entry.value.forEach { child ->
RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum ->
childSum.directParentName = parent.displayName()
childSum.directParentNames.add(parent.displayName())
if (childSum.flattenParentIds == null) {
childSum.flattenParentIds = ""

View File

@ -207,7 +207,7 @@ class RoomSummaryItemFactory @Inject constructor(
private fun getSearchResultSubtitle(roomSummary: RoomSummary): String {
val userId = roomSummary.directUserId
val directParent = roomSummary.directParentName
val directParent = roomSummary.directParentNames.lastOrNull()
val canonicalAlias = roomSummary.canonicalAlias
return (userId ?: directParent ?: canonicalAlias).orEmpty()