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 { is CurrentSpace.Space -> item {
SpaceHeaderView( SpaceHeaderView(
avatarData = space.spaceRoom.getAvatarData(AvatarSize.SpaceHeader), avatarData = space.spaceRoom.getAvatarData(AvatarSize.SpaceHeader),
name = space.spaceRoom.name, name = space.spaceRoom.displayName,
topic = space.spaceRoom.topic, topic = space.spaceRoom.topic,
visibility = space.spaceRoom.visibility, visibility = space.spaceRoom.visibility,
heroes = space.spaceRoom.heroes.toImmutableList(), heroes = space.spaceRoom.heroes.toImmutableList(),

View file

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

View file

@ -277,7 +277,7 @@ private fun RoomPreviewInfo.toContentState(membershipDetails: RoomMembershipDeta
private fun SpaceRoom.toContentState(): ContentState { private fun SpaceRoom.toContentState(): ContentState {
return ContentState.Loaded( return ContentState.Loaded(
roomId = roomId, roomId = roomId,
name = name, name = displayName,
topic = topic, topic = topic,
alias = canonicalAlias, alias = canonicalAlias,
numberOfMembers = numJoinedMembers.toLong(), numberOfMembers = numJoinedMembers.toLong(),

View file

@ -129,7 +129,7 @@ class LeaveSpacePresenter(
} }
return LeaveSpaceState( return LeaveSpaceState(
spaceName = leaveSpaceRooms.dataOrNull()?.current?.spaceRoom?.name, spaceName = leaveSpaceRooms.dataOrNull()?.current?.spaceRoom?.displayName,
isLastAdmin = leaveSpaceRooms.dataOrNull()?.current?.isLastAdmin == true, isLastAdmin = leaveSpaceRooms.dataOrNull()?.current?.isLastAdmin == true,
selectableSpaceRooms = selectableSpaceRooms, selectableSpaceRooms = selectableSpaceRooms,
leaveSpaceAction = leaveSpaceAction.value, leaveSpaceAction = leaveSpaceAction.value,

View file

@ -276,13 +276,7 @@ private fun SpaceItem(
Text( Text(
modifier = Modifier modifier = Modifier
.padding(end = 16.dp), .padding(end = 16.dp),
text = room.name ?: stringResource( text = room.displayName,
if (room.isSpace) {
CommonStrings.common_no_space_name
} else {
CommonStrings.common_no_room_name
},
),
color = ElementTheme.colors.textPrimary, color = ElementTheme.colors.textPrimary,
style = ElementTheme.typography.fontBodyLgMedium, style = ElementTheme.typography.fontBodyLgMedium,
maxLines = 1, maxLines = 1,

View file

@ -132,7 +132,7 @@ private fun SpaceViewContent(
item { item {
SpaceHeaderView( SpaceHeaderView(
avatarData = currentSpace.getAvatarData(AvatarSize.SpaceHeader), avatarData = currentSpace.getAvatarData(AvatarSize.SpaceHeader),
name = currentSpace.name, name = currentSpace.displayName,
topic = currentSpace.topic, topic = currentSpace.topic,
visibility = currentSpace.visibility, visibility = currentSpace.visibility,
heroes = currentSpace.heroes.toImmutableList(), heroes = currentSpace.heroes.toImmutableList(),
@ -213,7 +213,7 @@ private fun SpaceViewTopBar(
title = { title = {
if (currentSpace != null) { if (currentSpace != null) {
SpaceAvatarAndNameRow( SpaceAvatarAndNameRow(
name = currentSpace.name, name = currentSpace.displayName,
avatarData = currentSpace.getAvatarData(AvatarSize.TimelineRoom), avatarData = currentSpace.getAvatarData(AvatarSize.TimelineRoom),
) )
} }

View file

@ -37,16 +37,5 @@ data class SpaceRoom(
) { ) {
val isSpace = roomType == RoomType.Space 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) 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.graphics.vector.ImageVector
import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -76,8 +75,7 @@ fun SpaceRoomItemView(
trailingAction = trailingAction, trailingAction = trailingAction,
) { ) {
NameAndIndicatorRow( NameAndIndicatorRow(
isSpace = spaceRoom.isSpace, name = spaceRoom.displayName,
name = spaceRoom.name,
showIndicator = showUnreadIndicator showIndicator = showUnreadIndicator
) )
Spacer(modifier = Modifier.height(1.dp)) Spacer(modifier = Modifier.height(1.dp))
@ -92,7 +90,6 @@ fun SpaceRoomItemView(
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
style = ElementTheme.typography.fontBodyMdRegular, style = ElementTheme.typography.fontBodyMdRegular,
text = info, text = info,
fontStyle = FontStyle.Italic.takeIf { spaceRoom.name == null },
color = ElementTheme.colors.textSecondary, color = ElementTheme.colors.textSecondary,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis
@ -138,8 +135,7 @@ private fun SubtitleRow(
@Composable @Composable
private fun NameAndIndicatorRow( private fun NameAndIndicatorRow(
isSpace: Boolean, name: String,
name: String?,
showIndicator: Boolean, showIndicator: Boolean,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
@ -151,8 +147,7 @@ private fun NameAndIndicatorRow(
Text( Text(
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
style = ElementTheme.typography.fontBodyLgMedium, style = ElementTheme.typography.fontBodyLgMedium,
text = name ?: stringResource(id = if (isSpace) CommonStrings.common_no_space_name else CommonStrings.common_no_room_name), text = name,
fontStyle = FontStyle.Italic.takeIf { name == null },
color = ElementTheme.colors.textPrimary, color = ElementTheme.colors.textPrimary,
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis overflow = TextOverflow.Ellipsis

View file

@ -20,7 +20,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
fun SpaceRoom.getAvatarData(size: AvatarSize) = AvatarData( fun SpaceRoom.getAvatarData(size: AvatarSize) = AvatarData(
id = roomId.value, id = roomId.value,
name = name, name = displayName,
url = avatarUrl, url = avatarUrl,
size = size, size = size,
) )