feature(space): use SpaceRoom.displayName from sdk

This commit is contained in:
ganfra
2025-10-07 20:15:46 +02:00
parent 365116a40a
commit dde6dd0ed5
9 changed files with 11 additions and 33 deletions

View File

@@ -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(),

View File

@@ -41,7 +41,7 @@ fun RoomInfo.toInviteData(): InviteData {
fun SpaceRoom.toInviteData(): InviteData {
return InviteData(
roomId = roomId,
roomName = name ?: roomId.value,
roomName = displayName,
isDm = false,
)
}

View File

@@ -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(),

View File

@@ -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,

View File

@@ -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,

View File

@@ -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),
)
}

View File

@@ -37,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)
}

View File

@@ -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

View File

@@ -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,
)