mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Room join : add presenter tests
This commit is contained in:
+9
-1
@@ -28,10 +28,18 @@ data class RoomDescription(
|
||||
val name: String,
|
||||
val description: String,
|
||||
val avatarUrl: String?,
|
||||
val canBeJoined: Boolean,
|
||||
val joinRule: JoinRule,
|
||||
val numberOfMembers: Long,
|
||||
) : Parcelable {
|
||||
|
||||
enum class JoinRule {
|
||||
PUBLIC,
|
||||
KNOCK,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
fun canBeJoined() = joinRule == JoinRule.PUBLIC || joinRule == JoinRule.KNOCK
|
||||
|
||||
fun avatarData(size: AvatarSize) = AvatarData(
|
||||
id = roomId.value,
|
||||
name = name,
|
||||
|
||||
+2
-2
@@ -70,7 +70,7 @@ fun aRoomDescriptionList(): ImmutableList<RoomDescription> {
|
||||
name = "Element X Android",
|
||||
description = "Element X is a secure, private and decentralized messenger.",
|
||||
avatarUrl = null,
|
||||
canBeJoined = true,
|
||||
joinRule = RoomDescription.JoinRule.PUBLIC,
|
||||
numberOfMembers = 2765,
|
||||
),
|
||||
RoomDescription(
|
||||
@@ -78,7 +78,7 @@ fun aRoomDescriptionList(): ImmutableList<RoomDescription> {
|
||||
name = "Element X iOS",
|
||||
description = "Element X is a secure, private and decentralized messenger.",
|
||||
avatarUrl = null,
|
||||
canBeJoined = false,
|
||||
joinRule = RoomDescription.JoinRule.UNKNOWN,
|
||||
numberOfMembers = 356,
|
||||
)
|
||||
)
|
||||
|
||||
+2
-2
@@ -274,7 +274,7 @@ private fun RoomDirectoryRoomRow(
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(enabled = roomDescription.canBeJoined, onClick = onClick)
|
||||
.clickable(onClick = onClick)
|
||||
.padding(
|
||||
top = 12.dp,
|
||||
bottom = 12.dp,
|
||||
@@ -306,7 +306,7 @@ private fun RoomDirectoryRoomRow(
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
if (roomDescription.canBeJoined) {
|
||||
if (roomDescription.canBeJoined()) {
|
||||
Text(
|
||||
text = stringResource(id = CommonStrings.action_join),
|
||||
color = ElementTheme.colors.textSuccessPrimary,
|
||||
|
||||
+5
-1
@@ -44,6 +44,10 @@ fun MatrixRoomDescription.toFeatureModel(): RoomDescription {
|
||||
description = description(),
|
||||
avatarUrl = avatarUrl,
|
||||
numberOfMembers = numberOfMembers,
|
||||
canBeJoined = joinRule == MatrixRoomDescription.JoinRule.PUBLIC,
|
||||
joinRule = when (joinRule) {
|
||||
MatrixRoomDescription.JoinRule.PUBLIC -> RoomDescription.JoinRule.PUBLIC
|
||||
MatrixRoomDescription.JoinRule.KNOCK -> RoomDescription.JoinRule.KNOCK
|
||||
MatrixRoomDescription.JoinRule.UNKNOWN -> RoomDescription.JoinRule.UNKNOWN
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user