Fixes upgraded room duplication

This commit is contained in:
ericdecanini 2022-05-30 17:04:10 +02:00
parent b0ce32e97e
commit af4f8d001e
2 changed files with 5 additions and 2 deletions

View file

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

View file

@ -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.members.ChangeMembershipState
import org.matrix.android.sdk.api.session.room.model.RoomType 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.SpaceChildInfo
import org.matrix.android.sdk.api.session.room.model.VersioningState
import org.matrix.android.sdk.api.util.toMatrixItem import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject import javax.inject.Inject
@ -110,6 +111,7 @@ class SpaceDirectoryController @Inject constructor(
?.filter { ?.filter {
it.parentRoomId == (data.hierarchyStack.lastOrNull() ?: data.spaceId) it.parentRoomId == (data.hierarchyStack.lastOrNull() ?: data.spaceId)
} }
?.filterNot { it.isUpgradedRoom(data) }
?: emptyList() ?: emptyList()
if (flattenChildInfo.isEmpty()) { 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.UPGRADED_ROOM_JOINED }
} }