RoomList: add avatar for rooms and date formatting

This commit is contained in:
ganfra 2022-11-02 19:04:29 +01:00
parent 1801bcfcd3
commit 9037b9b66b
16 changed files with 244 additions and 61 deletions

View file

@ -96,10 +96,21 @@ class MatrixClient internal constructor(
}
}
suspend fun loadMediaContentForSource(source: MediaSource): Result<List<UByte>> =
suspend fun loadMediaContentForSource(source: MediaSource): Result<ByteArray> =
withContext(dispatchers.io) {
runCatching {
client.getMediaContent(source)
client.getMediaContent(source).toUByteArray().toByteArray()
}
}
suspend fun loadMediaThumbnailForSource(
source: MediaSource,
width: Long,
height: Long
): Result<ByteArray> =
withContext(dispatchers.io) {
runCatching {
client.getMediaThumbnail(source, width.toULong(), height.toULong()).toUByteArray().toByteArray()
}
}

View file

@ -23,5 +23,5 @@ data class RoomSummaryDetails(
val avatarURLString: String?,
val lastMessage: CharSequence?,
val lastMessageTimestamp: Long?,
val unreadNotificationCount: UInt,
val unreadNotificationCount: Int,
)

View file

@ -126,7 +126,7 @@ internal class RustRoomSummaryDataSource(
name = room.name() ?: identifier,
isDirect = room.isDm() ?: false,
avatarURLString = room.fullRoom()?.avatarUrl(),
unreadNotificationCount = room.unreadNotifications().notificationCount(),
unreadNotificationCount = room.unreadNotifications().notificationCount().toInt(),
lastMessage = latestRoomMessage?.body,
lastMessageTimestamp = latestRoomMessage?.originServerTs
)