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 d0c074012c..38c80734e2 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 @@ -44,6 +44,7 @@ import io.element.android.libraries.matrix.api.verification.SessionVerificationS import io.element.android.libraries.matrix.api.verification.SessionVerifiedStatus import io.element.android.libraries.matrix.ui.model.MatrixUser import io.element.android.features.networkmonitor.api.NetworkStatus +import io.element.android.libraries.matrix.api.core.RoomId import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -177,8 +178,10 @@ class RoomListPresenter @Inject constructor( name = roomSummary.details.name, url = roomSummary.details.avatarURLString ) + val roomIdentifier = roomSummary.identifier() RoomListRoomSummary( id = roomSummary.identifier(), + roomId = RoomId(roomIdentifier), name = roomSummary.details.name, hasUnread = roomSummary.details.unreadNotificationCount > 0, timestamp = lastMessageTimestampFormatter.format(roomSummary.details.lastMessageTimestamp), 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 aad82eccc5..1dfa943660 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 @@ -21,6 +21,7 @@ import io.element.android.features.roomlist.impl.model.RoomListRoomSummary import io.element.android.features.roomlist.impl.model.RoomListRoomSummaryPlaceholders import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.designsystem.utils.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.ui.model.MatrixUser import kotlinx.collections.immutable.ImmutableList @@ -57,7 +58,8 @@ internal fun aRoomListRoomSummaryList(): ImmutableList { timestamp = "14:18", lastMessage = "A very very very very long message which suites on two lines", avatarData = AvatarData("!id", "R"), - id = "!roomId:domain" + id = "!roomId:domain", + roomId = RoomId("!roomId:domain") ), RoomListRoomSummary( name = "Room#2", @@ -65,7 +67,8 @@ internal fun aRoomListRoomSummaryList(): ImmutableList { timestamp = "14:16", lastMessage = "A short message", avatarData = AvatarData("!id", "Z"), - id = "!roomId2:domain" + id = "!roomId2:domain", + roomId = RoomId("!roomId2:domain") ), RoomListRoomSummaryPlaceholders.create("!roomId2:domain") ) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListView.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListView.kt index f8305f3eb4..8c591f2c2b 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListView.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/RoomListView.kt @@ -60,6 +60,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.Velocity import androidx.compose.ui.unit.dp +import io.element.android.features.networkmonitor.api.ui.ConnectivityIndicatorView import io.element.android.features.roomlist.impl.components.RoomListTopBar import io.element.android.features.roomlist.impl.components.RoomSummaryRow import io.element.android.features.roomlist.impl.model.RoomListRoomSummary @@ -76,7 +77,6 @@ import io.element.android.libraries.designsystem.theme.components.TextButton import io.element.android.libraries.designsystem.theme.roomListUnreadIndicator import io.element.android.libraries.designsystem.utils.LogCompositions import io.element.android.libraries.matrix.api.core.RoomId -import io.element.android.features.networkmonitor.api.ui.ConnectivityIndicatorView import kotlinx.coroutines.launch import io.element.android.libraries.designsystem.R as DrawableR import io.element.android.libraries.ui.strings.R as StringR @@ -114,6 +114,7 @@ fun RoomListContent( onInvitesClicked: () -> Unit = {}, ) { fun onRoomClicked(room: RoomListRoomSummary) { + if (room.roomId == null) return onRoomClicked(room.roomId) } 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 ca80dc513e..d938cce04f 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 @@ -17,13 +17,14 @@ package io.element.android.features.roomlist.impl.model import androidx.compose.runtime.Immutable +import io.element.android.libraries.core.data.tryOrNull import io.element.android.libraries.designsystem.components.avatar.AvatarData import io.element.android.libraries.matrix.api.core.RoomId @Immutable data class RoomListRoomSummary( val id: String, - val roomId: RoomId = RoomId(id), + val roomId: RoomId?, val name: String = "", val hasUnread: Boolean = false, val timestamp: String? = null, diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryPlaceholders.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryPlaceholders.kt index ba42bcff9a..d6de1544cb 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryPlaceholders.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummaryPlaceholders.kt @@ -23,6 +23,7 @@ object RoomListRoomSummaryPlaceholders { fun create(id: String): RoomListRoomSummary { return RoomListRoomSummary( id = id, + roomId = null, isPlaceholder = true, name = "Short name", timestamp = "hh:mm",