mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Give the id to AvatarData to be able to compute initial properly.
This commit is contained in:
committed by
Benoit Marty
parent
b439109d05
commit
443076f636
+4
-9
@@ -16,15 +16,8 @@
|
||||
|
||||
package io.element.android.features.roomlist
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import io.element.android.features.roomlist.model.RoomListEvents
|
||||
import io.element.android.features.roomlist.model.RoomListRoomSummary
|
||||
import io.element.android.features.roomlist.model.RoomListRoomSummaryPlaceholders
|
||||
@@ -107,7 +100,8 @@ class RoomListPresenter @Inject constructor(
|
||||
val userDisplayName = client.loadUserDisplayName().getOrNull()
|
||||
val avatarData =
|
||||
AvatarData(
|
||||
name = userDisplayName ?: client.userId().value,
|
||||
id = client.userId().value,
|
||||
name = userDisplayName,
|
||||
url = userAvatarUrl,
|
||||
size = AvatarSize.SMALL
|
||||
)
|
||||
@@ -136,6 +130,7 @@ class RoomListPresenter @Inject constructor(
|
||||
is RoomSummary.Empty -> RoomListRoomSummaryPlaceholders.create(roomSummary.identifier)
|
||||
is RoomSummary.Filled -> {
|
||||
val avatarData = AvatarData(
|
||||
id = roomSummary.identifier(),
|
||||
name = roomSummary.details.name,
|
||||
url = roomSummary.details.avatarURLString
|
||||
)
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ fun RoomListViewDarkPreview() = ElementPreviewDark { ContentToPreview() }
|
||||
private fun ContentToPreview() {
|
||||
RoomListView(
|
||||
aRoomListState().copy(
|
||||
matrixUser = MatrixUser(id = UserId("@id"), username = "User#1", avatarData = AvatarData("U")),
|
||||
matrixUser = MatrixUser(id = UserId("@id"), username = "User#1", avatarData = AvatarData("@id", "U")),
|
||||
roomList = stubbedRoomSummaries(),
|
||||
filter = "filter",
|
||||
)
|
||||
|
||||
+1
-1
@@ -239,7 +239,7 @@ fun DefaultRoomListTopBarDarkPreview() = ElementPreviewDark { DefaultRoomListTop
|
||||
@Composable
|
||||
private fun DefaultRoomListTopBarPreview() {
|
||||
DefaultRoomListTopBar(
|
||||
matrixUser = MatrixUser(UserId("id"), "Alice", AvatarData("Alice")),
|
||||
matrixUser = MatrixUser(UserId("@id"), "Alice", AvatarData("@id", "Alice")),
|
||||
scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState()),
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,6 +28,6 @@ data class RoomListRoomSummary(
|
||||
val hasUnread: Boolean = false,
|
||||
val timestamp: String? = null,
|
||||
val lastMessage: CharSequence? = null,
|
||||
val avatarData: AvatarData = AvatarData(),
|
||||
val avatarData: AvatarData = AvatarData(id, name),
|
||||
val isPlaceholder: Boolean = false,
|
||||
)
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ object RoomListRoomSummaryPlaceholders {
|
||||
name = "Short name",
|
||||
timestamp = "hh:mm",
|
||||
lastMessage = "Last message for placeholder",
|
||||
avatarData = AvatarData("S")
|
||||
avatarData = AvatarData(id, "S")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ internal fun stubbedRoomSummaries(): ImmutableList<RoomListRoomSummary> {
|
||||
hasUnread = true,
|
||||
timestamp = "14:18",
|
||||
lastMessage = "A very very very very long message which suites on two lines",
|
||||
avatarData = AvatarData("R"),
|
||||
avatarData = AvatarData("!id", "R"),
|
||||
id = "roomId"
|
||||
),
|
||||
RoomListRoomSummary(
|
||||
@@ -35,7 +35,7 @@ internal fun stubbedRoomSummaries(): ImmutableList<RoomListRoomSummary> {
|
||||
hasUnread = false,
|
||||
timestamp = "14:16",
|
||||
lastMessage = "A short message",
|
||||
avatarData = AvatarData("Z"),
|
||||
avatarData = AvatarData("!id", "Z"),
|
||||
id = "roomId2"
|
||||
),
|
||||
RoomListRoomSummaryPlaceholders.create("roomId2")
|
||||
|
||||
+1
-1
@@ -217,6 +217,6 @@ private val aRoomListRoomSummary = RoomListRoomSummary(
|
||||
hasUnread = true,
|
||||
timestamp = A_FORMATTED_DATE,
|
||||
lastMessage = A_MESSAGE,
|
||||
avatarData = AvatarData(name = A_ROOM_NAME),
|
||||
avatarData = AvatarData(id = A_ROOM_ID.value, name = A_ROOM_NAME),
|
||||
isPlaceholder = false,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user