diff --git a/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt index 6c2384e4e3..ea88150c78 100644 --- a/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomPresenter.kt @@ -214,6 +214,7 @@ internal fun ContentState.toInviteData(): InviteData? { return when (this) { is ContentState.Loaded -> InviteData( roomId = roomId, + // Note: name should not be null at this point, but use Id just in case... roomName = name ?: roomId.value, isDirect = isDirect ) diff --git a/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt index 48af082af8..49541938d2 100644 --- a/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt +++ b/features/joinroom/impl/src/main/kotlin/io/element/android/features/joinroom/impl/JoinRoomView.kt @@ -47,7 +47,6 @@ import io.element.android.libraries.designsystem.atomic.pages.HeaderFooterPage import io.element.android.libraries.designsystem.background.LightGradientBackground import io.element.android.libraries.designsystem.components.async.AsyncActionView import io.element.android.libraries.designsystem.components.avatar.Avatar -import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.designsystem.components.avatar.AvatarSize import io.element.android.libraries.designsystem.components.button.BackButton import io.element.android.libraries.designsystem.components.button.SuperButton @@ -196,19 +195,7 @@ private fun JoinRoomContent( RoomPreviewOrganism( modifier = modifier, avatar = { - if (contentState.name == null && contentState.roomAvatarUrl == null) { - // Use a Dash Avatar - Avatar( - AvatarData( - id = contentState.roomId.value, - name = "#", - url = null, - size = AvatarSize.RoomHeader, - ) - ) - } else { - Avatar(contentState.avatarData(AvatarSize.RoomHeader)) - } + Avatar(contentState.avatarData(AvatarSize.RoomHeader)) }, title = { if (contentState.name != null) { diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingStateProvider.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingStateProvider.kt index 1eb7c0389e..703050227e 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingStateProvider.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingStateProvider.kt @@ -42,16 +42,21 @@ private fun anEditDefaultNotificationSettingsState( ) = EditDefaultNotificationSettingState( isOneToOne = isOneToOne, mode = RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY, - roomsWithUserDefinedMode = persistentListOf(aRoomSummary()), + roomsWithUserDefinedMode = persistentListOf( + aRoomSummary("Room"), + aRoomSummary(null), + ), changeNotificationSettingAction = changeNotificationSettingAction, displayMentionsOnlyDisclaimer = displayMentionsOnlyDisclaimer, eventSink = {} ) -private fun aRoomSummary() = RoomSummary.Filled( +private fun aRoomSummary( + name: String?, +) = RoomSummary.Filled( aRoomSummaryDetails( roomId = RoomId("!roomId:domain"), - name = "Room", + name = name, avatarUrl = null, isDirect = false, lastMessage = null, diff --git a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingView.kt b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingView.kt index 9eca90fa54..1938a4b4f0 100644 --- a/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingView.kt +++ b/features/preferences/impl/src/main/kotlin/io/element/android/features/preferences/impl/notifications/edit/EditDefaultNotificationSettingView.kt @@ -21,6 +21,7 @@ import androidx.compose.foundation.selection.selectableGroup import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.tooling.preview.PreviewParameter import io.element.android.features.preferences.impl.R import io.element.android.libraries.designsystem.components.async.AsyncActionView @@ -100,7 +101,11 @@ fun EditDefaultNotificationSettingView( ) ListItem( headlineContent = { - Text(text = summary.details.name) + val roomName = summary.details.name + Text( + text = roomName ?: stringResource(id = CommonStrings.common_no_room_name), + fontStyle = FontStyle.Italic.takeIf { roomName == null } + ) }, supportingContent = { Text(text = subtitle) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContextMenu.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContextMenu.kt index 1ab51a5219..4d7a6b3855 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContextMenu.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListContextMenu.kt @@ -24,6 +24,8 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.tooling.preview.PreviewParameter import io.element.android.compound.theme.ElementTheme import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.libraries.designsystem.components.list.ListItemContent @@ -87,8 +89,9 @@ private fun RoomListModalBottomSheetContent( ListItem( headlineContent = { Text( - text = contextMenu.roomName, + text = contextMenu.roomName ?: stringResource(id = CommonStrings.common_no_room_name), style = ElementTheme.typography.fontBodyLgMedium, + fontStyle = FontStyle.Italic.takeIf { contextMenu.roomName == null } ) } ) @@ -192,22 +195,11 @@ private fun RoomListModalBottomSheetContent( // Remove this preview when the issue is fixed. @PreviewsDayNight @Composable -internal fun RoomListModalBottomSheetContentPreview() = ElementPreview { +internal fun RoomListModalBottomSheetContentPreview( + @PreviewParameter(RoomListStateContextMenuShownProvider::class) contextMenu: RoomListState.ContextMenu.Shown +) = ElementPreview { RoomListModalBottomSheetContent( - contextMenu = aContextMenuShown(hasNewContent = true), - onRoomMarkReadClicked = {}, - onRoomMarkUnreadClicked = {}, - onRoomSettingsClicked = {}, - onLeaveRoomClicked = {}, - onFavoriteChanged = {}, - ) -} - -@PreviewsDayNight -@Composable -internal fun RoomListModalBottomSheetContentForDmPreview() = ElementPreview { - RoomListModalBottomSheetContent( - contextMenu = aContextMenuShown(isDm = true), + contextMenu = contextMenu, onRoomMarkReadClicked = {}, onRoomMarkUnreadClicked = {}, onRoomSettingsClicked = {}, diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt index c455cdff17..e610c33571 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListPresenter.kt @@ -298,6 +298,7 @@ class RoomListPresenter @Inject constructor( @VisibleForTesting internal fun RoomListRoomSummary.toInviteData() = InviteData( roomId = roomId, - roomName = name, + // Note: `name` should not be null at this point, but just in case, fallback to the roomId + roomName = name ?: roomId.value, isDirect = isDirect, ) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt index ed72c622c7..9f5b0d6b0d 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListState.kt @@ -48,7 +48,7 @@ data class RoomListState( data object Hidden : ContextMenu data class Shown( val roomId: RoomId, - val roomName: String, + val roomName: String?, val isDm: Boolean, val isFavorite: Boolean, val markAsUnreadFeatureFlagEnabled: Boolean, diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListStateContextMenuShownProvider.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListStateContextMenuShownProvider.kt new file mode 100644 index 0000000000..309dd9b5a0 --- /dev/null +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListStateContextMenuShownProvider.kt @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.features.roomlist.impl + +import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import io.element.android.libraries.matrix.api.core.RoomId + +open class RoomListStateContextMenuShownProvider : PreviewParameterProvider { + override val values: Sequence + get() = sequenceOf( + aContextMenuShown(hasNewContent = true), + aContextMenuShown(isDm = true), + aContextMenuShown(roomName = null) + ) +} + +internal fun aContextMenuShown( + roomName: String? = "aRoom", + isDm: Boolean = false, + hasNewContent: Boolean = false, + isFavorite: Boolean = false, +) = RoomListState.ContextMenu.Shown( + roomId = RoomId("!aRoom:aDomain"), + roomName = roomName, + isDm = isDm, + markAsUnreadFeatureFlagEnabled = true, + hasNewContent = hasNewContent, + isFavorite = isFavorite, +) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListStateProvider.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListStateProvider.kt index bf73a74ef8..976040b5a7 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListStateProvider.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListStateProvider.kt @@ -32,7 +32,6 @@ import io.element.android.features.roomlist.impl.search.aRoomListSearchState import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.designsystem.components.avatar.AvatarSize import io.element.android.libraries.designsystem.utils.snackbar.SnackbarMessage -import io.element.android.libraries.matrix.api.core.RoomId import io.element.android.libraries.matrix.api.core.UserId import io.element.android.libraries.matrix.api.user.MatrixUser import io.element.android.libraries.ui.strings.CommonStrings @@ -45,6 +44,7 @@ open class RoomListStateProvider : PreviewParameterProvider { aRoomListState(), aRoomListState(snackbarMessage = SnackbarMessage(CommonStrings.common_verification_complete)), aRoomListState(hasNetworkConnection = false), + aRoomListState(contextMenu = aContextMenuShown(roomName = null)), aRoomListState(contextMenu = aContextMenuShown(roomName = "A nice room name")), aRoomListState(contextMenu = aContextMenuShown(isFavorite = true)), aRoomListState(contentState = aRoomsContentState(securityBannerState = SecurityBannerState.RecoveryKeyConfirmation)), @@ -109,7 +109,7 @@ internal fun aRoomListRoomSummaryList(): ImmutableList { ), aRoomListRoomSummary( id = "!roomId3:domain", - displayType = RoomSummaryDisplayType.PLACEHOLDER, + displayType = RoomSummaryDisplayType.PLACEHOLDER, ), aRoomListRoomSummary( id = "!roomId4:domain", @@ -117,17 +117,3 @@ internal fun aRoomListRoomSummaryList(): ImmutableList { ), ) } - -internal fun aContextMenuShown( - roomName: String = "aRoom", - isDm: Boolean = false, - hasNewContent: Boolean = false, - isFavorite: Boolean = false, -) = RoomListState.ContextMenu.Shown( - roomId = RoomId("!aRoom:aDomain"), - roomName = roomName, - isDm = isDm, - markAsUnreadFeatureFlagEnabled = true, - hasNewContent = hasNewContent, - isFavorite = isFavorite, -) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt index 77a93c46c1..a14140297c 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt @@ -41,6 +41,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.AnnotatedString +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 @@ -168,7 +169,7 @@ private fun RoomSummaryScaffoldRow( @Composable private fun NameAndTimestampRow( - name: String, + name: String?, timestamp: String?, isHighlighted: Boolean, modifier: Modifier = Modifier @@ -181,7 +182,8 @@ private fun NameAndTimestampRow( Text( modifier = Modifier.weight(1f), style = ElementTheme.typography.fontBodyLgMedium, - text = name, + text = name ?: stringResource(id = CommonStrings.common_no_room_name), + fontStyle = FontStyle.Italic.takeIf { name == null }, color = MaterialTheme.roomListRoomName(), maxLines = 1, overflow = TextOverflow.Ellipsis @@ -272,7 +274,7 @@ private fun LastMessageAndIndicatorRow( @Composable private fun InviteNameAndIndicatorRow( - name: String, + name: String?, modifier: Modifier = Modifier, ) { Row( @@ -283,7 +285,8 @@ private fun InviteNameAndIndicatorRow( Text( modifier = Modifier.weight(1f), style = ElementTheme.typography.fontBodyLgMedium, - text = name, + text = name ?: stringResource(id = CommonStrings.common_no_room_name), + fontStyle = FontStyle.Italic.takeIf { name == null }, color = MaterialTheme.roomListRoomName(), maxLines = 1, overflow = TextOverflow.Ellipsis diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt index 84c4cd45c3..9afa6cd749 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt @@ -28,7 +28,7 @@ data class RoomListRoomSummary( val id: String, val displayType: RoomSummaryDisplayType, val roomId: RoomId, - val name: String, + val name: String?, val canonicalAlias: RoomAlias?, val numberOfUnreadMessages: Int, val numberOfUnreadMentions: Int, diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryProvider.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryProvider.kt index 005044e60d..a39d50eac0 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryProvider.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryProvider.kt @@ -31,6 +31,7 @@ open class RoomListRoomSummaryProvider : PreviewParameterProvider var startIndex = 0 val initial = dn[startIndex] diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/roomlist/RoomSummary.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/roomlist/RoomSummary.kt index 2ab50630a1..425da8d3ca 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/roomlist/RoomSummary.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/roomlist/RoomSummary.kt @@ -37,7 +37,7 @@ sealed interface RoomSummary { data class RoomSummaryDetails( val roomId: RoomId, - val name: String, + val name: String?, val canonicalAlias: RoomAlias?, val isDirect: Boolean, val avatarUrl: String?, diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFilter.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFilter.kt index 3aac08c823..d7f2acf87d 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFilter.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomListFilter.kt @@ -40,7 +40,7 @@ val RoomListFilter.predicate (roomSummary.details.numUnreadNotifications > 0 || roomSummary.details.isMarkedUnread) } is RoomListFilter.NormalizedMatchRoomName -> { roomSummary: RoomSummary -> - roomSummary is RoomSummary.Filled && roomSummary.details.name.contains(pattern, ignoreCase = true) + roomSummary is RoomSummary.Filled && roomSummary.details.name.orEmpty().contains(pattern, ignoreCase = true) } RoomListFilter.Invite -> { roomSummary: RoomSummary -> roomSummary.isInvited() diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryDetailsFactory.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryDetailsFactory.kt index a70030cc70..a0c283cb1e 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryDetailsFactory.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/roomlist/RoomSummaryDetailsFactory.kt @@ -33,7 +33,7 @@ class RoomSummaryDetailsFactory(private val roomMessageFactory: RoomMessageFacto } return RoomSummaryDetails( roomId = RoomId(roomInfo.id), - name = roomInfo.name ?: roomInfo.id, + name = roomInfo.name, canonicalAlias = roomInfo.canonicalAlias?.let(::RoomAlias), isDirect = roomInfo.isDirect, avatarUrl = roomInfo.avatarUrl, diff --git a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/RoomSummaryFixture.kt b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/RoomSummaryFixture.kt index 6b9383ef05..d9fdffa62a 100644 --- a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/RoomSummaryFixture.kt +++ b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/RoomSummaryFixture.kt @@ -63,7 +63,7 @@ fun aRoomSummaryFilled( fun aRoomSummaryDetails( roomId: RoomId = A_ROOM_ID, - name: String = A_ROOM_NAME, + name: String? = A_ROOM_NAME, isDirect: Boolean = false, avatarUrl: String? = null, lastMessage: RoomMessage? = aRoomMessage(), diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/RoomSummaryDetailsProvider.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/RoomSummaryDetailsProvider.kt index 764d34ca25..a433f49395 100644 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/RoomSummaryDetailsProvider.kt +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/RoomSummaryDetailsProvider.kt @@ -29,12 +29,13 @@ open class RoomSummaryDetailsProvider : PreviewParameterProvider get() = sequenceOf( aRoomSummaryDetails(), + aRoomSummaryDetails(name = null), ) } fun aRoomSummaryDetails( roomId: RoomId = RoomId("!room:domain"), - name: String = "roomName", + name: String? = "roomName", canonicalAlias: RoomAlias? = null, isDirect: Boolean = true, avatarUrl: String? = null, diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedRoom.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedRoom.kt index eeefc2dc65..c95f3e4cde 100644 --- a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedRoom.kt +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/SelectedRoom.kt @@ -62,7 +62,8 @@ fun SelectedRoom( ) { Avatar(AvatarData(roomSummary.roomId.value, roomSummary.name, roomSummary.avatarUrl, AvatarSize.SelectedRoom)) Text( - text = roomSummary.name, + // If name is null, we do not have space to render "No room name", so just use `#` here. + text = roomSummary.name ?: "#", overflow = TextOverflow.Ellipsis, maxLines = 1, style = MaterialTheme.typography.bodyLarge, diff --git a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt index 5a32a64ac1..77eb7b9845 100644 --- a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt +++ b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectPresenter.kt @@ -57,7 +57,7 @@ class RoomSelectPresenter @AssistedInject constructor( LaunchedEffect(query, summaries) { val filteredSummaries = summaries.filterIsInstance() .map { it.details } - .filter { it.name.contains(query, ignoreCase = true) } + .filter { it.name.orEmpty().contains(query, ignoreCase = true) } .distinctBy { it.roomId } // This should be removed once we're sure no duplicate Rooms can be received .toPersistentList() results = if (filteredSummaries.isNotEmpty()) { diff --git a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectStateProvider.kt b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectStateProvider.kt index f0daf8b7fa..d9b6f3f040 100644 --- a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectStateProvider.kt +++ b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectStateProvider.kt @@ -68,4 +68,7 @@ private fun aForwardMessagesRoomList() = persistentListOf( name = "Room with alias", canonicalAlias = RoomAlias("#alias:example.org"), ), + aRoomSummaryDetails( + name = null, + ), ) diff --git a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectView.kt b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectView.kt index eb6143107f..9c351a3a9e 100644 --- a/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectView.kt +++ b/libraries/roomselect/impl/src/main/kotlin/io/element/android/libraries/roomselect/impl/RoomSelectView.kt @@ -235,7 +235,8 @@ private fun RoomSummaryView( // Name Text( style = ElementTheme.typography.fontBodyLgRegular, - text = summary.name, + // If name is null, we do not have space to render "No room name", so just use `#` here. + text = summary.name ?: "#", color = ElementTheme.colors.textPrimary, maxLines = 1, overflow = TextOverflow.Ellipsis diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt index be7780b4e7..6145e9bcdc 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistPreviewTest.kt @@ -101,7 +101,6 @@ class KonsistPreviewTest { "PollContentViewEndedPreview", "PollContentViewUndisclosedPreview", "ReadReceiptBottomSheetPreview", - "RoomListModalBottomSheetContentForDmPreview", "RoomMemberListViewBannedPreview", "SasEmojisPreview", "SecureBackupSetupViewChangePreview",