Changes ordering of room subtitles used

This commit is contained in:
ericdecanini 2022-05-02 14:42:56 +02:00
parent 47493fcfa1
commit c9b32fec44
2 changed files with 19 additions and 6 deletions

View file

@ -349,27 +349,39 @@ internal class RoomSummaryUpdater @Inject constructor(
} }
val acyclicGraph = graph.withoutEdges(backEdges) val acyclicGraph = graph.withoutEdges(backEdges)
// Timber.v("## SPACES: acyclicGraph $acyclicGraph")
val flattenSpaceParents = acyclicGraph.flattenDestination().map { val flattenSpaceParents = acyclicGraph.flattenDestination().map {
it.key.name to it.value.map { it.name } it.key.name to it.value.map { it.name }
}.toMap() }.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 lookupMap.entries
.filter { it.key.roomType == RoomType.SPACE && it.key.membership == Membership.JOIN } .filter { it.key.roomType == RoomType.SPACE && it.key.membership == Membership.JOIN }
.forEach { entry -> .forEach { entry ->
val parent = RoomSummaryEntity.where(realm, entry.key.roomId).findFirst() val parent = RoomSummaryEntity.where(realm, entry.key.roomId).findFirst()
if (parent != null) { if (parent != null) {
// Timber.v("## SPACES: check hierarchy of ${parent.name} id ${parent.roomId}")
// Timber.v("## SPACES: flat known parents of ${parent.name} are ${flattenSpaceParents[parent.roomId]}")
val flattenParentsIds = (flattenSpaceParents[parent.roomId] ?: emptyList()) + listOf(parent.roomId) val flattenParentsIds = (flattenSpaceParents[parent.roomId] ?: emptyList()) + listOf(parent.roomId)
// Timber.v("## SPACES: flatten known parents of children of ${parent.name} are ${flattenParentsIds}")
entry.value.forEach { child -> entry.value.forEach { child ->
RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum -> RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum ->
// Timber.w("## SPACES: ${childSum.name} is ${childSum.roomId} fc: ${childSum.flattenParentIds}")
// var allParents = childSum.flattenParentIds ?: ""
if (childSum.flattenParentIds == null) childSum.flattenParentIds = "" if (childSum.flattenParentIds == null) childSum.flattenParentIds = ""
flattenParentsIds.forEach { flattenParentsIds.forEach {
if (childSum.flattenParentIds?.contains(it) != true) { if (childSum.flattenParentIds?.contains(it) != true) {
if (childSum.flattenParentIds?.isEmpty() == false) { childSum.flattenParentIds += "|$it"
childSum.flattenParentIds += "|"
}
childSum.flattenParentIds += it
} }
} }
// childSum.flattenParentIds = "$allParents|"
// Timber.v("## SPACES: flatten of ${childSum.name} is ${childSum.flattenParentIds}")
} }
} }
} }
@ -399,6 +411,7 @@ internal class RoomSummaryUpdater @Inject constructor(
// we keep real m.child/m.parent relations and add the one for common memberships // we keep real m.child/m.parent relations and add the one for common memberships
dmRoom.flattenParentIds += "|${flattenRelated.joinToString("|")}|" dmRoom.flattenParentIds += "|${flattenRelated.joinToString("|")}|"
} }
// Timber.v("## SPACES: flatten of ${dmRoom.otherMemberIds.joinToString(",")} is ${dmRoom.flattenParentIds}")
} }
// Maybe a good place to count the number of notifications for spaces? // Maybe a good place to count the number of notifications for spaces?

View file

@ -153,10 +153,10 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
} }
private fun getSearchResultSubtitle(roomSummary: RoomSummary): String { private fun getSearchResultSubtitle(roomSummary: RoomSummary): String {
val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name
val userId = roomSummary.directUserId val userId = roomSummary.directUserId
val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name
val canonicalAlias = roomSummary.canonicalAlias val canonicalAlias = roomSummary.canonicalAlias
return (spaceName ?: userId ?: canonicalAlias).orEmpty() return (userId ?: spaceName ?: canonicalAlias).orEmpty()
} }
} }