Merge pull request #6200 from vector-im/bugfix/eric/upgrade-room-deduplication

Fixes room not being in space after upgrade
This commit is contained in:
Eric Decanini 2022-07-20 12:30:42 +02:00 committed by GitHub
commit 38ba61f144
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 3 deletions

1
changelog.d/6200.bugfix Normal file
View file

@ -0,0 +1 @@
Fixes room not being in space after upgrade

View file

@ -33,5 +33,7 @@ enum class VersioningState {
/**
* The room has been upgraded, and the new room has been joined.
*/
UPGRADED_ROOM_JOINED,
UPGRADED_ROOM_JOINED;
fun isUpgraded() = this != NONE
}

View file

@ -84,8 +84,6 @@ class UpgradeRoomViewModelTask @Inject constructor(
// autoJoin = currentInfo.autoJoin ?: false,
suggested = currentInfo.suggested
)
parentSpace.removeChildren(params.roomId)
}
}
} catch (failure: Throwable) {

View file

@ -110,6 +110,7 @@ class SpaceDirectoryController @Inject constructor(
?.filter {
it.parentRoomId == (data.hierarchyStack.lastOrNull() ?: data.spaceId)
}
?.filterNot { it.isUpgradedRoom(data) }
?: 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() }
}

View file

@ -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
}
}