Add Konsist test to check that toPersistentList() is not used.
Same for `toPersistentSet()` and `toPersistentMap()`. Fix existing issues.
This commit is contained in:
parent
2fa1b9d448
commit
67c9daa0bf
85 changed files with 305 additions and 254 deletions
|
|
@ -77,7 +77,7 @@ import io.element.android.libraries.sessionstorage.api.SessionStore
|
|||
import io.element.android.services.toolbox.api.systemclock.SystemClock
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.TimeoutCancellationException
|
||||
import kotlinx.coroutines.cancel
|
||||
|
|
@ -238,11 +238,11 @@ class RustMatrixClient(
|
|||
|
||||
override val ignoredUsersFlow = mxCallbackFlow<ImmutableList<UserId>> {
|
||||
// Fetch the initial value manually, the SDK won't return it automatically
|
||||
channel.trySend(innerClient.ignoredUsers().map(::UserId).toPersistentList())
|
||||
channel.trySend(innerClient.ignoredUsers().map(::UserId).toImmutableList())
|
||||
|
||||
innerClient.subscribeToIgnoredUsers(object : IgnoredUsersListener {
|
||||
override fun call(ignoredUserIds: List<String>) {
|
||||
channel.trySend(ignoredUserIds.map(::UserId).toPersistentList())
|
||||
channel.trySend(ignoredUserIds.map(::UserId).toImmutableList())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import io.element.android.libraries.matrix.impl.room.member.RoomMemberMapper
|
|||
import io.element.android.libraries.matrix.impl.room.powerlevels.RoomPowerLevelsValuesMapper
|
||||
import io.element.android.libraries.matrix.impl.room.tombstone.map
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentMap
|
||||
import kotlinx.collections.immutable.toImmutableMap
|
||||
import org.matrix.rustcomponents.sdk.Membership
|
||||
import org.matrix.rustcomponents.sdk.RoomHero
|
||||
import uniffi.matrix_sdk_base.EncryptionState
|
||||
|
|
@ -103,6 +103,6 @@ fun RoomHero.map(): MatrixUser = MatrixUser(
|
|||
fun mapPowerLevels(roomPowerLevels: RustRoomPowerLevels): RoomPowerLevels {
|
||||
return RoomPowerLevels(
|
||||
values = RoomPowerLevelsValuesMapper.map(roomPowerLevels.values()),
|
||||
users = roomPowerLevels.userPowerLevels().mapKeys { (key, _) -> UserId(key) }.toPersistentMap()
|
||||
users = roomPowerLevels.userPowerLevels().mapKeys { (key, _) -> UserId(key) }.toImmutableMap()
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
package io.element.android.libraries.matrix.impl.room.join
|
||||
|
||||
import io.element.android.libraries.matrix.api.room.join.JoinRule
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import org.matrix.rustcomponents.sdk.JoinRule as RustJoinRule
|
||||
|
||||
fun RustJoinRule.map(): JoinRule {
|
||||
|
|
@ -17,9 +17,9 @@ fun RustJoinRule.map(): JoinRule {
|
|||
RustJoinRule.Private -> JoinRule.Private
|
||||
RustJoinRule.Knock -> JoinRule.Knock
|
||||
RustJoinRule.Invite -> JoinRule.Invite
|
||||
is RustJoinRule.Restricted -> JoinRule.Restricted(rules.map { it.map() }.toPersistentList())
|
||||
is RustJoinRule.Restricted -> JoinRule.Restricted(rules.map { it.map() }.toImmutableList())
|
||||
is RustJoinRule.Custom -> JoinRule.Custom(repr)
|
||||
is RustJoinRule.KnockRestricted -> JoinRule.KnockRestricted(rules.map { it.map() }.toPersistentList())
|
||||
is RustJoinRule.KnockRestricted -> JoinRule.KnockRestricted(rules.map { it.map() }.toImmutableList())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@
|
|||
package io.element.android.libraries.matrix.impl.room
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.room.CurrentUserMembership
|
||||
import io.element.android.libraries.matrix.api.room.RoomInfo
|
||||
import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
||||
|
|
@ -34,7 +31,6 @@ import io.element.android.libraries.matrix.test.room.defaultRoomPowerLevelValues
|
|||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.persistentMapOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import org.junit.Test
|
||||
import org.matrix.rustcomponents.sdk.Membership
|
||||
import uniffi.matrix_sdk_base.EncryptionState
|
||||
|
|
@ -113,15 +109,15 @@ class RoomInfoMapperTest {
|
|||
notificationCount = 11L,
|
||||
userDefinedNotificationMode = RoomNotificationMode.MUTE,
|
||||
hasRoomCall = true,
|
||||
activeRoomCallParticipants = listOf(A_USER_ID_3).toImmutableList(),
|
||||
heroes = listOf(
|
||||
activeRoomCallParticipants = persistentListOf(A_USER_ID_3),
|
||||
heroes = persistentListOf(
|
||||
MatrixUser(
|
||||
userId = A_USER_ID,
|
||||
displayName = "displayName",
|
||||
avatarUrl = "avatarUrl",
|
||||
)
|
||||
).toImmutableList(),
|
||||
pinnedEventIds = listOf(AN_EVENT_ID).toPersistentList(),
|
||||
),
|
||||
pinnedEventIds = persistentListOf(AN_EVENT_ID),
|
||||
creators = persistentListOf(A_USER_ID),
|
||||
isMarkedUnread = false,
|
||||
numUnreadMessages = 12L,
|
||||
|
|
@ -191,7 +187,7 @@ class RoomInfoMapperTest {
|
|||
successorRoom = null,
|
||||
isFavorite = true,
|
||||
canonicalAlias = null,
|
||||
alternativeAliases = emptyList<RoomAlias>().toPersistentList(),
|
||||
alternativeAliases = persistentListOf(),
|
||||
currentUserMembership = CurrentUserMembership.INVITED,
|
||||
inviter = null,
|
||||
activeMembersCount = 2L,
|
||||
|
|
@ -205,9 +201,9 @@ class RoomInfoMapperTest {
|
|||
notificationCount = 11L,
|
||||
userDefinedNotificationMode = null,
|
||||
hasRoomCall = false,
|
||||
activeRoomCallParticipants = emptyList<UserId>().toImmutableList(),
|
||||
heroes = emptyList<MatrixUser>().toImmutableList(),
|
||||
pinnedEventIds = emptyList<EventId>().toPersistentList(),
|
||||
activeRoomCallParticipants = persistentListOf(),
|
||||
heroes = persistentListOf(),
|
||||
pinnedEventIds = persistentListOf(),
|
||||
creators = persistentListOf(),
|
||||
isMarkedUnread = true,
|
||||
numUnreadMessages = 12L,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue