-
Notifications
You must be signed in to change notification settings - Fork 731
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
Fixes room not being in space after upgrade #6200
Changes from 3 commits
af4f8d0
8d93044
01b7395
f6b0e8d
36fc2fb
e87d970
654eede
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fixes room not being in space after upgrade | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ import org.matrix.android.sdk.api.failure.MatrixError.Companion.M_UNRECOGNIZED | |
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState | ||
import org.matrix.android.sdk.api.session.room.model.RoomType | ||
import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo | ||
import org.matrix.android.sdk.api.session.room.model.VersioningState | ||
import org.matrix.android.sdk.api.util.toMatrixItem | ||
import javax.inject.Inject | ||
|
||
|
@@ -110,6 +111,7 @@ class SpaceDirectoryController @Inject constructor( | |
?.filter { | ||
it.parentRoomId == (data.hierarchyStack.lastOrNull() ?: data.spaceId) | ||
} | ||
?.filterNot { it.isUpgradedRoom(data) } | ||
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. it will filter out rooms with 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. This is intentional yeah, this only applies to the old version of upgraded rooms, so them not being active there's no use having them shown in Explore Rooms 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. Just to clarify, we should filter out if the room is an old version of a room that is also in the space (we want to avoid apparant duplicates in the list). 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. So, when room is upgraded, everyone in the room gets tombstone event and state is changed to 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. We should check what web is doing and do the same. What we don't want is for the user to see a duplicated room (for the user it's pretty much the same, after all room upgrade is just a technical thing). 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. We already have a de-duplication mechanism for upgraded room in the room list. We need similar thing in the explore screen 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. 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. But you don't keep it, you filter out any room with 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 mean keep in the sense that it's not deleted from the space in the db, it's just filtered out in the UI |
||
?: emptyList() | ||
|
||
if (flattenChildInfo.isEmpty()) { | ||
|
@@ -209,4 +211,7 @@ class SpaceDirectoryController @Inject constructor( | |
} | ||
} | ||
} | ||
|
||
private fun SpaceChildInfo.isUpgradedRoom(data: SpaceDirectoryState) = | ||
data.knownRoomSummaries.any { it.roomId == childRoomId && it.versioningState != VersioningState.NONE } | ||
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. super nit: could be a little easier on the brain to lift the has the benefit of keeping the conditions here positive and future proofs this logic from any possible new versioning states which aren't upgrades 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 agree, good shout! |
||
} |
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.
do we know why this was originally added?
I would assume the room id is changed after upgrade and we're cleaning the legacy room 🤔
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.
I would guess this was the first attempt at removing the duplication, and though it worked for that purpose, you would no longer see the pre-upgraded room in the space but you'd see it in Home
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.
This could be valuable for other cases, some counters could use spaces children number or some check (if space is empty or not), so absence of removal could cause some side effects.
@BillCarsonFr you added this line, maybe you could verify if removing it could cause any problems?
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 in the original code when migrating a room, we were removing the old room from the space and then add the new one. The annoying side effect is that people that haven't yet migrated will then see the room as not being in the space anymore (it will probably jump back to
home
).Now we want to keep both old & new as part of the migration process, and to have the UI smarter and detect duplicate rooms and only show the new one.
Like that new comers will only see the new room, and existing users will see the old one in the space with the CTA to join the migrated one.
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.
I was thinking about some places, where we could get rooms without applying this filter, like getting space''s room count or something like that. 🤔