Skip to content
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

Merged
merged 7 commits into from
Jul 20, 2022

Conversation

ericdecanini
Copy link
Contributor

@ericdecanini ericdecanini commented May 31, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

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

  • In a space, go to a room with two of your test accounts and use the /upgraderoom 7 to upgrade the room from 9 to 7 (yes this still counts as an upgrade). Don't automatically reinvite users
  • On your other test account, ensure that you still see the room in the same space but going into it shows you that it's been upgraded
  • Invite your account and see that the room disappears and gets replaced by the invite
  • After accepting the invite see that in explore rooms you no longer see the pre-upgrade room

Tested devices

  • Physical
  • Emulator
  • OS version(s): Android 12 (both)

Checklist

@ericdecanini ericdecanini added the PR-Small PR with less than 20 updated lines label May 31, 2022
@@ -84,8 +84,6 @@ class UpgradeRoomViewModelTask @Inject constructor(
// autoJoin = currentInfo.autoJoin ?: false,
suggested = currentInfo.suggested
)

parentSpace.removeChildren(params.roomId)
Copy link
Contributor

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 🤔

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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. 🤔

@github-actions
Copy link

github-actions bot commented May 31, 2022

Unit Test Results

128 files   - 22  128 suites   - 22   2m 15s ⏱️ -15s
223 tests  - 16  223 ✔️  - 16  0 💤 ±0  0 ±0 
738 runs   - 62  738 ✔️  - 62  0 💤 ±0  0 ±0 

Results for commit 36fc2fb. ± Comparison against base commit d586f64.

♻️ This comment has been updated with latest results.

@ericdecanini ericdecanini marked this pull request as draft May 31, 2022 10:41
@ericdecanini ericdecanini marked this pull request as ready for review May 31, 2022 11:00
Copy link
Contributor

@ouchadam ouchadam left a 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 }
Copy link
Contributor

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

Copy link
Contributor Author

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) }
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Member

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).

Copy link
Contributor

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?

Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see web doing this same as this PR. The pre-upgraded room is kept in the space

image

Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Base automatically changed from bugfix/eric/fix-upgrade-room to develop June 17, 2022 08:55
…e-room-deduplication

# Conflicts:
#	matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/VersioningState.kt
Copy link
Member

@BillCarsonFr BillCarsonFr left a 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.

@ericdecanini
Copy link
Contributor Author

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? vector-im/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

#6411

@BillCarsonFr
Copy link
Member

BillCarsonFr commented Jul 1, 2022

Is it possible to add a unit/integration test?

@sonarcloud
Copy link

sonarcloud bot commented Jul 4, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

28.6% 28.6% Coverage
0.0% 0.0% Duplication

@ericdecanini ericdecanini merged commit 38ba61f into develop Jul 20, 2022
@ericdecanini ericdecanini deleted the bugfix/eric/upgrade-room-deduplication branch July 20, 2022 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Small PR with less than 20 updated lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better handle room upgrades within Spaces
4 participants