-
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 all 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 @@ | ||
Fixes room not being in space after upgrade |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 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 +210,7 @@ class SpaceDirectoryController @Inject constructor( | |
} | ||
} | ||
} | ||
|
||
private fun SpaceChildInfo.isUpgradedRoom(data: SpaceDirectoryState) = | ||
data.knownRoomSummaries.any { it.roomId == childRoomId && it.versioningState.isUpgraded() } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.matrix.android.sdk.api.session.room.model | ||
|
||
import org.amshove.kluent.shouldBe | ||
import org.junit.Test | ||
|
||
internal class VersioningStateTest { | ||
|
||
@Test | ||
fun `when VersioningState is NONE, then isUpgraded returns false`() { | ||
val versioningState = VersioningState.NONE | ||
|
||
val isUpgraded = versioningState.isUpgraded() | ||
|
||
isUpgraded shouldBe false | ||
} | ||
|
||
@Test | ||
fun `when VersioningState is UPGRADED_ROOM_NOT_JOINED, then isUpgraded returns true`() { | ||
val versioningState = VersioningState.UPGRADED_ROOM_NOT_JOINED | ||
|
||
val isUpgraded = versioningState.isUpgraded() | ||
|
||
isUpgraded shouldBe true | ||
} | ||
|
||
@Test | ||
fun `when VersioningState is UPGRADED_ROOM_JOINED, then isUpgraded returns true`() { | ||
val versioningState = VersioningState.UPGRADED_ROOM_JOINED | ||
|
||
val isUpgraded = versioningState.isUpgraded() | ||
|
||
isUpgraded shouldBe true | ||
} | ||
} |
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. 🤔