-
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
Conversation
@@ -84,8 +84,6 @@ class UpgradeRoomViewModelTask @Inject constructor( | |||
// autoJoin = currentInfo.autoJoin ?: false, | |||
suggested = currentInfo.suggested | |||
) | |||
|
|||
parentSpace.removeChildren(params.roomId) |
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. 🤔
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'm not tooo familiar with Spaces
, codewise this looks good to me! 💯
@@ -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 comment
The 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 isUpgraded = it.versioningState != VersioningState.NONE
to an extension on the VersioningState
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, good shout!
@@ -110,6 +110,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 comment
The reason will be displayed to describe this comment to others. Learn more.
it will filter out rooms with UPGRADED_ROOM_NOT_JOINED
VersioningState, is it intentional? If room was upgraded, but user haven't joined upgraded room yet, what user will see? We change state from NONE
to UPGRADED_ROOM_NOT_JOINED
on TombStone event and so it could happen while user is on a background and doesn't interact with the app.
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 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 comment
The 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 comment
The 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 UPGRADED_ROOM_NOT_JOINED
until they will join new room. isUpgradedRoom
will return true and so such users won't see room in a list. Shouldn't we hide it only after users will join new 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.
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).
I guess that in the case you mentionned, I would want as a user to see only one room and probably that I joined?
So that mean we show the old room? or the new one but with an indicator that I joined the old version?
anyhow we should align with web and amend later with better behavior if needed
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
But you don't keep it, you filter out any room with UPGRADED_ROOM_NOT_JOINED
, so it's different from web, no?
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 mean keep in the sense that it's not deleted from the space in the db, it's just filtered out in the UI
@@ -84,8 +84,6 @@ class UpgradeRoomViewModelTask @Inject constructor( | |||
// autoJoin = currentInfo.autoJoin ?: false, | |||
suggested = currentInfo.suggested | |||
) | |||
|
|||
parentSpace.removeChildren(params.roomId) |
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?
…to bugfix/eric/upgrade-room-deduplication
…e-room-deduplication # Conflicts: # matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/VersioningState.kt
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 noticed that this change is not consistent with web (did some tests).
Could you please sync with web and see why they are not doing it?
element-hq/element-meta#460
We should be consistent.
We have this issue to decide and fix what should happen with regards to the room showing after an upgrade. This PR focuses on fixing the orphaning (issue you linked) and deduplication of the room after an upgrade. I think we should keep the focus of this PR on only that and any other changes, we address it in this issue below. This will also give us enough time to fix it for both web and android and gain parity again |
Is it possible to add a unit/integration test? |
SonarCloud Quality Gate failed. |
Type of change
Content
Fixes room not being in space after upgrade and possible duplications in Explore Rooms
Motivation and context
Closes #4133
Screenshots / GIFs
dedupe.mp4
Tests
/upgraderoom 7
to upgrade the room from 9 to 7 (yes this still counts as an upgrade). Don't automatically reinvite usersTested devices
Checklist