mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 03:06:14 +00:00
Merge pull request #7371 from hayaksi1/fix/5428-send-to-room-subtitle
Show the alias or the direct message user's Matrix ID in the room picker
This commit is contained in:
+3
@@ -87,6 +87,7 @@ internal fun aSelectRoomInfoList(): ImmutableList<SelectRoomInfo> = listOf(
|
||||
canonicalAlias = null,
|
||||
avatarUrl = null,
|
||||
heroes = persistentListOf(),
|
||||
isDm = false,
|
||||
isTombstoned = false,
|
||||
),
|
||||
SelectRoomInfo(
|
||||
@@ -95,6 +96,7 @@ internal fun aSelectRoomInfoList(): ImmutableList<SelectRoomInfo> = listOf(
|
||||
canonicalAlias = null,
|
||||
avatarUrl = null,
|
||||
heroes = persistentListOf(),
|
||||
isDm = false,
|
||||
isTombstoned = false,
|
||||
),
|
||||
SelectRoomInfo(
|
||||
@@ -103,6 +105,7 @@ internal fun aSelectRoomInfoList(): ImmutableList<SelectRoomInfo> = listOf(
|
||||
canonicalAlias = null,
|
||||
avatarUrl = null,
|
||||
heroes = persistentListOf(),
|
||||
isDm = false,
|
||||
isTombstoned = false,
|
||||
),
|
||||
).toImmutableList()
|
||||
|
||||
+2
@@ -31,6 +31,7 @@ fun aSelectRoomInfo(
|
||||
canonicalAlias: RoomAlias? = null,
|
||||
avatarUrl: String? = null,
|
||||
heroes: ImmutableList<MatrixUser> = persistentListOf(),
|
||||
isDm: Boolean = false,
|
||||
isTombstoned: Boolean = false,
|
||||
) = SelectRoomInfo(
|
||||
roomId = roomId,
|
||||
@@ -38,5 +39,6 @@ fun aSelectRoomInfo(
|
||||
canonicalAlias = canonicalAlias,
|
||||
avatarUrl = avatarUrl,
|
||||
heroes = heroes,
|
||||
isDm = isDm,
|
||||
isTombstoned = isTombstoned,
|
||||
)
|
||||
|
||||
+2
@@ -23,6 +23,7 @@ data class SelectRoomInfo(
|
||||
val canonicalAlias: RoomAlias?,
|
||||
val avatarUrl: String?,
|
||||
val heroes: ImmutableList<MatrixUser>,
|
||||
val isDm: Boolean,
|
||||
val isTombstoned: Boolean,
|
||||
) {
|
||||
fun getAvatarData(size: AvatarSize) = AvatarData(
|
||||
@@ -41,5 +42,6 @@ fun RoomInfo.toSelectRoomInfo() = SelectRoomInfo(
|
||||
avatarUrl = avatarUrl,
|
||||
heroes = heroes,
|
||||
canonicalAlias = canonicalAlias,
|
||||
isDm = isDm,
|
||||
isTombstoned = successorRoom != null,
|
||||
)
|
||||
|
||||
+9
@@ -13,6 +13,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
||||
import io.element.android.libraries.matrix.ui.components.aSelectRoomInfo
|
||||
import io.element.android.libraries.matrix.ui.model.SelectRoomInfo
|
||||
import io.element.android.libraries.roomselect.api.RoomSelectMode
|
||||
@@ -79,5 +80,13 @@ internal fun aRoomSelectRoomList() = persistentListOf(
|
||||
),
|
||||
aSelectRoomInfo(
|
||||
roomId = RoomId("!room3:domain"),
|
||||
name = "Alice",
|
||||
heroes = persistentListOf(
|
||||
aMatrixUser(id = "@alice:example.org", displayName = "Alice"),
|
||||
),
|
||||
isDm = true,
|
||||
),
|
||||
aSelectRoomInfo(
|
||||
roomId = RoomId("!room4:domain"),
|
||||
),
|
||||
)
|
||||
|
||||
+4
-3
@@ -260,10 +260,11 @@ private fun RoomSummaryView(
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
// Alias
|
||||
roomInfo.canonicalAlias?.let { alias ->
|
||||
val otherUserId = roomInfo.heroes.singleOrNull()?.userId?.takeIf { roomInfo.isDm }
|
||||
val subtitle = roomInfo.canonicalAlias?.value ?: otherUserId?.value
|
||||
if (subtitle != null) {
|
||||
Text(
|
||||
text = alias.value,
|
||||
text = subtitle,
|
||||
color = ElementTheme.colors.textSecondary,
|
||||
style = ElementTheme.typography.fontBodySmRegular,
|
||||
maxLines = 1,
|
||||
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
@file:OptIn(ExperimentalTestApi::class)
|
||||
|
||||
package io.element.android.libraries.roomselect.impl
|
||||
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.ui.test.AndroidComposeUiTest
|
||||
import androidx.compose.ui.test.ExperimentalTestApi
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.v2.runAndroidComposeUiTest
|
||||
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.ui.components.aMatrixUser
|
||||
import io.element.android.libraries.matrix.ui.components.aSelectRoomInfo
|
||||
import io.element.android.tests.testutils.EnsureNeverCalled
|
||||
import io.element.android.tests.testutils.EnsureNeverCalledWithParam
|
||||
import io.element.android.tests.testutils.robolectric.RobolectricTest
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import org.junit.Test
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
class RoomSelectViewTest : RobolectricTest() {
|
||||
@Config(qualifiers = "h1024dp")
|
||||
@Test
|
||||
fun `a room with a canonical alias renders the alias`() = runAndroidComposeUiTest {
|
||||
setRoomSelectView(
|
||||
aRoomSelectState(
|
||||
resultState = SearchBarResultState.Results(aRoomSelectRoomList()),
|
||||
),
|
||||
)
|
||||
onNodeWithText("Room with alias").assertIsDisplayed()
|
||||
onNodeWithText("#alias:example.org").assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Config(qualifiers = "h1024dp")
|
||||
@Test
|
||||
fun `a direct message without alias renders the matrix id of the other user`() = runAndroidComposeUiTest {
|
||||
setRoomSelectView(
|
||||
aRoomSelectState(
|
||||
resultState = SearchBarResultState.Results(aRoomSelectRoomList()),
|
||||
),
|
||||
)
|
||||
onNodeWithText("Alice").assertIsDisplayed()
|
||||
onNodeWithText("@alice:example.org").assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Config(qualifiers = "h1024dp")
|
||||
@Test
|
||||
fun `a room which is not a direct message does not render the matrix id of its hero`() = runAndroidComposeUiTest {
|
||||
setRoomSelectView(
|
||||
aRoomSelectState(
|
||||
resultState = SearchBarResultState.Results(
|
||||
persistentListOf(
|
||||
aSelectRoomInfo(
|
||||
roomId = RoomId("!room:domain"),
|
||||
name = "Room with a single hero",
|
||||
heroes = persistentListOf(
|
||||
aMatrixUser(id = "@alice:example.org", displayName = "Alice"),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
onNodeWithText("Room with a single hero").assertIsDisplayed()
|
||||
onNodeWithText("@alice:example.org").assertDoesNotExist()
|
||||
}
|
||||
}
|
||||
|
||||
private fun AndroidComposeUiTest<ComponentActivity>.setRoomSelectView(
|
||||
state: RoomSelectState,
|
||||
onDismiss: () -> Unit = EnsureNeverCalled(),
|
||||
onSubmit: (List<RoomId>) -> Unit = EnsureNeverCalledWithParam(),
|
||||
) {
|
||||
setContent {
|
||||
RoomSelectView(
|
||||
state = state,
|
||||
onDismiss = onDismiss,
|
||||
onSubmit = onSubmit,
|
||||
)
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user