Merge pull request #5476 from element-hq/feature/fga/space_room_display_name
Space : makes sure to use SpaceRoom.displayName from sdk
This commit is contained in:
@@ -39,7 +39,7 @@ fun HomeSpacesView(
|
||||
is CurrentSpace.Space -> item {
|
||||
SpaceHeaderView(
|
||||
avatarData = space.spaceRoom.getAvatarData(AvatarSize.SpaceHeader),
|
||||
name = space.spaceRoom.name,
|
||||
name = space.spaceRoom.displayName,
|
||||
topic = space.spaceRoom.topic,
|
||||
visibility = space.spaceRoom.visibility,
|
||||
heroes = space.spaceRoom.heroes.toImmutableList(),
|
||||
|
||||
@@ -30,7 +30,6 @@ class SpaceRoomProvider : PreviewParameterProvider<SpaceRoom> {
|
||||
roomId = RoomId("!spaceId1:example.com"),
|
||||
),
|
||||
aSpaceRoom(
|
||||
rawName = null,
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
@@ -38,14 +37,5 @@ class SpaceRoomProvider : PreviewParameterProvider<SpaceRoom> {
|
||||
roomId = RoomId("!spaceId2:example.com"),
|
||||
state = CurrentUserMembership.INVITED,
|
||||
),
|
||||
aSpaceRoom(
|
||||
rawName = null,
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
avatarUrl = "anUrl",
|
||||
roomId = RoomId("!spaceId3:example.com"),
|
||||
state = CurrentUserMembership.INVITED,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ fun RoomInfo.toInviteData(): InviteData {
|
||||
fun SpaceRoom.toInviteData(): InviteData {
|
||||
return InviteData(
|
||||
roomId = roomId,
|
||||
roomName = name ?: roomId.value,
|
||||
roomName = displayName,
|
||||
isDm = false,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ private fun RoomPreviewInfo.toContentState(membershipDetails: RoomMembershipDeta
|
||||
private fun SpaceRoom.toContentState(): ContentState {
|
||||
return ContentState.Loaded(
|
||||
roomId = roomId,
|
||||
name = name,
|
||||
name = displayName,
|
||||
topic = topic,
|
||||
alias = canonicalAlias,
|
||||
numberOfMembers = numJoinedMembers.toLong(),
|
||||
|
||||
@@ -129,7 +129,7 @@ class LeaveSpacePresenter(
|
||||
}
|
||||
|
||||
return LeaveSpaceState(
|
||||
spaceName = leaveSpaceRooms.dataOrNull()?.current?.spaceRoom?.name,
|
||||
spaceName = leaveSpaceRooms.dataOrNull()?.current?.spaceRoom?.displayName,
|
||||
isLastAdmin = leaveSpaceRooms.dataOrNull()?.current?.isLastAdmin == true,
|
||||
selectableSpaceRooms = selectableSpaceRooms,
|
||||
leaveSpaceAction = leaveSpaceAction.value,
|
||||
|
||||
@@ -30,7 +30,7 @@ class LeaveSpaceStateProvider : PreviewParameterProvider<LeaveSpaceState> {
|
||||
persistentListOf(
|
||||
aSelectableSpaceRoom(
|
||||
spaceRoom = aSpaceRoom(
|
||||
rawName = "A long space name that should be truncated",
|
||||
displayName = "A long space name that should be truncated",
|
||||
worldReadable = true,
|
||||
),
|
||||
isLastAdmin = true,
|
||||
|
||||
@@ -276,13 +276,7 @@ private fun SpaceItem(
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.padding(end = 16.dp),
|
||||
text = room.name ?: stringResource(
|
||||
if (room.isSpace) {
|
||||
CommonStrings.common_no_space_name
|
||||
} else {
|
||||
CommonStrings.common_no_room_name
|
||||
},
|
||||
),
|
||||
text = room.displayName,
|
||||
color = ElementTheme.colors.textPrimary,
|
||||
style = ElementTheme.typography.fontBodyLgMedium,
|
||||
maxLines = 1,
|
||||
|
||||
@@ -37,7 +37,6 @@ open class SpaceStateProvider : PreviewParameterProvider<SpaceState> {
|
||||
),
|
||||
aSpaceState(
|
||||
parentSpace = aSpaceRoom(
|
||||
rawName = null,
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
|
||||
@@ -132,7 +132,7 @@ private fun SpaceViewContent(
|
||||
item {
|
||||
SpaceHeaderView(
|
||||
avatarData = currentSpace.getAvatarData(AvatarSize.SpaceHeader),
|
||||
name = currentSpace.name,
|
||||
name = currentSpace.displayName,
|
||||
topic = currentSpace.topic,
|
||||
visibility = currentSpace.visibility,
|
||||
heroes = currentSpace.heroes.toImmutableList(),
|
||||
@@ -213,7 +213,7 @@ private fun SpaceViewTopBar(
|
||||
title = {
|
||||
if (currentSpace != null) {
|
||||
SpaceAvatarAndNameRow(
|
||||
name = currentSpace.name,
|
||||
name = currentSpace.displayName,
|
||||
avatarData = currentSpace.getAvatarData(AvatarSize.TimelineRoom),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.junit.Test
|
||||
class LeaveSpacePresenterTest {
|
||||
private val aSpace = aSpaceRoom(
|
||||
roomId = A_SPACE_ID,
|
||||
rawName = A_SPACE_NAME,
|
||||
displayName = A_SPACE_NAME,
|
||||
)
|
||||
|
||||
@Test
|
||||
@@ -198,7 +198,7 @@ class LeaveSpacePresenterTest {
|
||||
private fun aLeaveSpaceRoom(
|
||||
spaceRoom: SpaceRoom = aSpaceRoom(
|
||||
roomId = A_SPACE_ID,
|
||||
rawName = A_SPACE_NAME,
|
||||
displayName = A_SPACE_NAME,
|
||||
),
|
||||
isLastAdmin: Boolean = false,
|
||||
) = LeaveSpaceRoom(
|
||||
|
||||
@@ -52,7 +52,7 @@ class SpaceViewTest {
|
||||
|
||||
@Test
|
||||
fun `clicking on a room name invokes the expected callback`() {
|
||||
val aSpaceRoom = aSpaceRoom(roomId = A_ROOM_ID, rawName = A_ROOM_NAME)
|
||||
val aSpaceRoom = aSpaceRoom(roomId = A_ROOM_ID, displayName = A_ROOM_NAME)
|
||||
val eventsRecorder = EventsRecorder<SpaceEvents>(expectEvents = false)
|
||||
ensureCalledOnceWithParam(aSpaceRoom) {
|
||||
rule.setSpaceView(
|
||||
|
||||
@@ -167,7 +167,7 @@ test_detekt_test = { module = "io.gitlab.arturbosch.detekt:detekt-test", version
|
||||
# https://github.com/matrix-org/matrix-rust-components-kotlin/commits/main/sdk/sdk-android/src/main/kotlin/org/matrix/rustcomponents/sdk/matrix_sdk_ffi.kt
|
||||
# All new features should not be implemented in the pull request that upgrades the version, developers should
|
||||
# only fix API breaks and may add some TODOs.
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:25.10.2"
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:25.10.7"
|
||||
|
||||
# Others
|
||||
coil = { module = "io.coil-kt.coil3:coil", version.ref = "coil" }
|
||||
|
||||
@@ -16,6 +16,7 @@ import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
|
||||
data class SpaceRoom(
|
||||
val rawName: String?,
|
||||
val displayName: String,
|
||||
val avatarUrl: String?,
|
||||
val canonicalAlias: RoomAlias?,
|
||||
val childrenCount: Int,
|
||||
@@ -36,16 +37,5 @@ data class SpaceRoom(
|
||||
) {
|
||||
val isSpace = roomType == RoomType.Space
|
||||
|
||||
/**
|
||||
* Temporary logic to compute a name for direct rooms with no name.
|
||||
* This will be replaced by sdk logic in the future.
|
||||
*/
|
||||
val name = if (rawName == null && isDirect == true && heroes.size == 1) {
|
||||
val dmRecipient = heroes.first()
|
||||
dmRecipient.displayName
|
||||
} else {
|
||||
rawName
|
||||
}
|
||||
|
||||
val visibility = SpaceRoomVisibility.fromJoinRule(joinRule)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ class SpaceRoomMapper {
|
||||
guestCanJoin = spaceRoom.guestCanJoin,
|
||||
heroes = spaceRoom.heroes.orEmpty().map { it.map() },
|
||||
joinRule = spaceRoom.joinRule?.map(),
|
||||
rawName = spaceRoom.name,
|
||||
rawName = spaceRoom.rawName,
|
||||
displayName = spaceRoom.displayName,
|
||||
numJoinedMembers = spaceRoom.numJoinedMembers.toInt(),
|
||||
roomId = RoomId(spaceRoom.roomId),
|
||||
roomType = spaceRoom.roomType.map(),
|
||||
|
||||
@@ -19,7 +19,8 @@ fun aRustSpaceRoom(
|
||||
roomId: RoomId = A_ROOM_ID,
|
||||
isDirect: Boolean = false,
|
||||
canonicalAlias: String? = null,
|
||||
name: String? = null,
|
||||
rawName: String? = null,
|
||||
displayName: String = "",
|
||||
topic: String? = null,
|
||||
avatarUrl: String? = null,
|
||||
roomType: RoomType = RoomType.Space,
|
||||
@@ -34,7 +35,8 @@ fun aRustSpaceRoom(
|
||||
roomId = roomId.value,
|
||||
isDirect = isDirect,
|
||||
canonicalAlias = canonicalAlias,
|
||||
name = name,
|
||||
rawName = rawName,
|
||||
displayName = displayName,
|
||||
topic = topic,
|
||||
avatarUrl = avatarUrl,
|
||||
roomType = roomType,
|
||||
|
||||
@@ -29,7 +29,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -76,8 +75,7 @@ fun SpaceRoomItemView(
|
||||
trailingAction = trailingAction,
|
||||
) {
|
||||
NameAndIndicatorRow(
|
||||
isSpace = spaceRoom.isSpace,
|
||||
name = spaceRoom.name,
|
||||
name = spaceRoom.displayName,
|
||||
showIndicator = showUnreadIndicator
|
||||
)
|
||||
Spacer(modifier = Modifier.height(1.dp))
|
||||
@@ -92,7 +90,6 @@ fun SpaceRoomItemView(
|
||||
modifier = Modifier.weight(1f),
|
||||
style = ElementTheme.typography.fontBodyMdRegular,
|
||||
text = info,
|
||||
fontStyle = FontStyle.Italic.takeIf { spaceRoom.name == null },
|
||||
color = ElementTheme.colors.textSecondary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
@@ -138,8 +135,7 @@ private fun SubtitleRow(
|
||||
|
||||
@Composable
|
||||
private fun NameAndIndicatorRow(
|
||||
isSpace: Boolean,
|
||||
name: String?,
|
||||
name: String,
|
||||
showIndicator: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
@@ -151,8 +147,7 @@ private fun NameAndIndicatorRow(
|
||||
Text(
|
||||
modifier = Modifier.weight(1f),
|
||||
style = ElementTheme.typography.fontBodyLgMedium,
|
||||
text = name ?: stringResource(id = if (isSpace) CommonStrings.common_no_space_name else CommonStrings.common_no_room_name),
|
||||
fontStyle = FontStyle.Italic.takeIf { name == null },
|
||||
text = name,
|
||||
color = ElementTheme.colors.textPrimary,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
|
||||
@@ -18,17 +18,16 @@ class SpaceRoomProvider : PreviewParameterProvider<SpaceRoom> {
|
||||
override val values: Sequence<SpaceRoom> = sequenceOf(
|
||||
aSpaceRoom(
|
||||
roomType = RoomType.Room,
|
||||
rawName = "Room name with topic",
|
||||
displayName = "Room name with topic",
|
||||
topic = "Room topic that is quite long and might be truncated"
|
||||
),
|
||||
aSpaceRoom(
|
||||
roomType = RoomType.Room,
|
||||
rawName = "Room name no topic",
|
||||
displayName = "Room name no topic",
|
||||
state = CurrentUserMembership.LEFT,
|
||||
),
|
||||
aSpaceRoom(
|
||||
roomType = RoomType.Room,
|
||||
rawName = null,
|
||||
isDirect = true,
|
||||
heroes = listOf(aMatrixUser(displayName = "Alice")),
|
||||
state = CurrentUserMembership.JOINED,
|
||||
@@ -36,13 +35,13 @@ class SpaceRoomProvider : PreviewParameterProvider<SpaceRoom> {
|
||||
),
|
||||
aSpaceRoom(
|
||||
roomType = RoomType.Room,
|
||||
rawName = "Room name with topic",
|
||||
displayName = "Room name with topic",
|
||||
topic = "Room topic that is quite long and might be truncated",
|
||||
state = CurrentUserMembership.INVITED,
|
||||
),
|
||||
aSpaceRoom(
|
||||
roomType = RoomType.Room,
|
||||
rawName = "Room name no topic",
|
||||
displayName = "Room name no topic",
|
||||
state = CurrentUserMembership.INVITED,
|
||||
),
|
||||
aSpaceRoom(
|
||||
@@ -60,7 +59,6 @@ class SpaceRoomProvider : PreviewParameterProvider<SpaceRoom> {
|
||||
state = CurrentUserMembership.LEFT,
|
||||
),
|
||||
aSpaceRoom(
|
||||
rawName = null,
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
@@ -68,14 +66,5 @@ class SpaceRoomProvider : PreviewParameterProvider<SpaceRoom> {
|
||||
roomId = RoomId("!spaceId2:example.com"),
|
||||
state = CurrentUserMembership.INVITED,
|
||||
),
|
||||
aSpaceRoom(
|
||||
rawName = null,
|
||||
numJoinedMembers = 5,
|
||||
childrenCount = 10,
|
||||
worldReadable = true,
|
||||
avatarUrl = "anUrl",
|
||||
roomId = RoomId("!spaceId3:example.com"),
|
||||
state = CurrentUserMembership.INVITED,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
||||
fun SpaceRoom.getAvatarData(size: AvatarSize) = AvatarData(
|
||||
id = roomId.value,
|
||||
name = name,
|
||||
name = displayName,
|
||||
url = avatarUrl,
|
||||
size = size,
|
||||
)
|
||||
|
||||
@@ -16,7 +16,8 @@ import io.element.android.libraries.matrix.api.spaces.SpaceRoom
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
|
||||
fun aSpaceRoom(
|
||||
rawName: String? = "Space name",
|
||||
rawName: String? = null,
|
||||
displayName: String = "Space name",
|
||||
avatarUrl: String? = null,
|
||||
canonicalAlias: RoomAlias? = null,
|
||||
childrenCount: Int = 0,
|
||||
@@ -33,6 +34,7 @@ fun aSpaceRoom(
|
||||
via: List<String> = emptyList(),
|
||||
) = SpaceRoom(
|
||||
rawName = rawName,
|
||||
displayName = displayName,
|
||||
avatarUrl = avatarUrl,
|
||||
canonicalAlias = canonicalAlias,
|
||||
childrenCount = childrenCount,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user