Let JoinRule and AllowRule be Immutable.
This commit is contained in:
@@ -58,6 +58,7 @@ import io.element.android.tests.testutils.lambda.assert
|
||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||
import io.element.android.tests.testutils.lambda.value
|
||||
import io.element.android.tests.testutils.test
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.test.runTest
|
||||
@@ -913,7 +914,7 @@ class JoinRoomPresenterTest {
|
||||
val client = FakeMatrixClient(
|
||||
getNotJoinedRoomResult = { _, _ ->
|
||||
Result.success(
|
||||
aRoomPreview(info = aRoomPreviewInfo(joinRule = JoinRule.KnockRestricted(emptyList())))
|
||||
aRoomPreview(info = aRoomPreviewInfo(joinRule = JoinRule.KnockRestricted(persistentListOf())))
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -933,7 +934,7 @@ class JoinRoomPresenterTest {
|
||||
val client = FakeMatrixClient(
|
||||
getNotJoinedRoomResult = { _, _ ->
|
||||
Result.success(
|
||||
aRoomPreview(info = aRoomPreviewInfo(joinRule = JoinRule.Restricted(emptyList())))
|
||||
aRoomPreview(info = aRoomPreviewInfo(joinRule = JoinRule.Restricted(persistentListOf())))
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
|
||||
package io.element.android.libraries.matrix.api.room.join
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
|
||||
@Immutable
|
||||
sealed interface AllowRule {
|
||||
data class RoomMembership(val roomId: RoomId) : AllowRule
|
||||
data class Custom(val json: String) : AllowRule
|
||||
|
||||
@@ -7,12 +7,16 @@
|
||||
|
||||
package io.element.android.libraries.matrix.api.room.join
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
sealed interface JoinRule {
|
||||
data object Public : JoinRule
|
||||
data object Private : JoinRule
|
||||
data object Knock : JoinRule
|
||||
data object Invite : JoinRule
|
||||
data class Restricted(val rules: List<AllowRule>) : JoinRule
|
||||
data class KnockRestricted(val rules: List<AllowRule>) : JoinRule
|
||||
data class Restricted(val rules: ImmutableList<AllowRule>) : JoinRule
|
||||
data class KnockRestricted(val rules: ImmutableList<AllowRule>) : JoinRule
|
||||
data class Custom(val value: String) : JoinRule
|
||||
}
|
||||
|
||||
@@ -8,6 +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 org.matrix.rustcomponents.sdk.JoinRule as RustJoinRule
|
||||
|
||||
fun RustJoinRule.map(): JoinRule {
|
||||
@@ -16,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() })
|
||||
is RustJoinRule.Restricted -> JoinRule.Restricted(rules.map { it.map() }.toPersistentList())
|
||||
is RustJoinRule.Custom -> JoinRule.Custom(repr)
|
||||
is RustJoinRule.KnockRestricted -> JoinRule.KnockRestricted(rules.map { it.map() })
|
||||
is RustJoinRule.KnockRestricted -> JoinRule.KnockRestricted(rules.map { it.map() }.toPersistentList())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user