-
Notifications
You must be signed in to change notification settings - Fork 739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaces subtitle in Search Rooms with room context rather than last event #5860
Changes from 13 commits
0250f61
a3367d4
9e53e6c
70cded2
87ad35d
3347560
b280358
4784717
962e9ab
7e415e8
7cc79fe
a355b62
f70a24d
47493fc
c9b32fe
b46794d
52c404a
21fe5a2
50839c2
7c1d1c3
83bd9bc
03acf45
d12ab17
a5dc8ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
package org.matrix.android.sdk.internal.session.room.summary | ||
|
||
import io.realm.Realm | ||
import io.realm.RealmList | ||
import io.realm.kotlin.createObject | ||
import kotlinx.coroutines.runBlocking | ||
import org.matrix.android.sdk.api.extensions.orFalse | ||
|
@@ -349,39 +350,34 @@ 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 } | ||
.forEach { entry -> | ||
val parent = RoomSummaryEntity.where(realm, entry.key.roomId).findFirst() | ||
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) | ||
// Timber.v("## SPACES: flatten known parents of children of ${parent.name} are ${flattenParentsIds}") | ||
entry.value.forEach { child -> | ||
RoomSummaryEntity.where(realm, child.roomId).findFirst()?.let { childSum -> | ||
|
||
// Timber.w("## SPACES: ${childSum.name} is ${childSum.roomId} fc: ${childSum.flattenParentIds}") | ||
// var allParents = childSum.flattenParentIds ?: "" | ||
// TODO: Revisit | ||
childSum.parents.add(SpaceParentSummaryEntity( | ||
canonical = true, | ||
parentRoomId = parent.roomId, | ||
parentSummaryEntity = parent, | ||
viaServers = RealmList() | ||
)) | ||
if (childSum.flattenParentIds == null) childSum.flattenParentIds = "" | ||
flattenParentsIds.forEach { | ||
if (childSum.flattenParentIds?.contains(it) != true) { | ||
childSum.flattenParentIds += "|$it" | ||
if (childSum.flattenParentIds?.isEmpty() == false) { | ||
childSum.flattenParentIds += "|" | ||
} | ||
childSum.flattenParentIds += it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes a bug where the first element of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it a bug? What was not working? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. E.g. if a room had one parent, its Idk if it has any user-facing impact but I believe this isn't expected behaviour in the code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am surprised we didn't get report on this, maybe the RoomSummaryMapper is doing some cleaning? None the less I would submit this as a separate PR. |
||
} | ||
} | ||
// childSum.flattenParentIds = "$allParents|" | ||
|
||
// Timber.v("## SPACES: flatten of ${childSum.name} is ${childSum.flattenParentIds}") | ||
} | ||
} | ||
} | ||
|
@@ -411,7 +407,6 @@ internal class RoomSummaryUpdater @Inject constructor( | |
// we keep real m.child/m.parent relations and add the one for common memberships | ||
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? | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BillCarsonFr @bmarty @ganfra can you guys give me more context surrounding this please.
I added this block to add the parents of a room (spaces, etc) as they currently weren't being added, but the
canonical = true
andviaServers = RealmList()
are currently placeholders as I don't know what they are or what they should be.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove this part. Parent is only for m.space.parent state event.
We are not adding a parent link because you are a child.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does a child have no knowledge of its parent then, other than through
flattenParentIds
? This is confusing because eachroomSummary
has the fieldspaceParents
which is currently often empty.Ultimately as well, we would like to be able to know a room's parent in its summary object so we can achieve the same as what web does here (the space of the room is displayed in search)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes parent is really when there is a m.space.parent state event in the room (and a valid one, added by an admin in both rooms).
It's not really used right now, it's more to help for discovery, when you join a room from a link the UI could prompt a tip to propose you to join the space.
I think you can use flattenParentsIds for the use case you mentioned.