Unify the way we decide whether a room is a DM or a group room (#3100)

* Add centralised 'room is DM' check

Also add extension functions for `MatrixRoom` and `MatrixRoomInfo`.

* Use the centralised method and extension functions through the app, including:

- Room list.
- Room details screen.
- Invites.
- Notifications.

Replace most `isDirect` usages with `isDm`.

* Update screenshots

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
Jorge Martin Espinosa 2024-07-10 18:28:46 +02:00 committed by GitHub
parent 1a03edbe63
commit 0be7058416
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 195 additions and 73 deletions

View file

@ -290,5 +290,5 @@ internal fun RoomListRoomSummary.toInviteData() = InviteData(
roomId = roomId,
// Note: `name` should not be null at this point, but just in case, fallback to the roomId
roomName = name ?: roomId.value,
isDirect = isDirect,
isDm = isDm,
)

View file

@ -95,8 +95,8 @@ internal fun RoomSummaryRow(
modifier = modifier
) {
InviteNameAndIndicatorRow(name = room.name)
InviteSubtitle(isDirect = room.isDirect, inviteSender = room.inviteSender, canonicalAlias = room.canonicalAlias)
if (!room.isDirect && room.inviteSender != null) {
InviteSubtitle(isDm = room.isDm, inviteSender = room.inviteSender, canonicalAlias = room.canonicalAlias)
if (!room.isDm && room.inviteSender != null) {
Spacer(modifier = Modifier.height(4.dp))
InviteSenderView(
modifier = Modifier.fillMaxWidth(),
@ -206,12 +206,12 @@ private fun NameAndTimestampRow(
@Composable
private fun InviteSubtitle(
isDirect: Boolean,
isDm: Boolean,
inviteSender: InviteSender?,
canonicalAlias: RoomAlias?,
modifier: Modifier = Modifier
) {
val subtitle = if (isDirect) {
val subtitle = if (isDm) {
inviteSender?.userId?.value
} else {
canonicalAlias?.value

View file

@ -45,7 +45,7 @@ class RoomListRoomSummaryFactory @Inject constructor(
isMarkedUnread = details.isMarkedUnread,
timestamp = lastMessageTimestampFormatter.format(details.lastMessageTimestamp),
lastMessage = details.lastMessage?.let { message ->
roomLastMessageFormatter.format(message.event, details.isDirect)
roomLastMessageFormatter.format(message.event, details.isDm)
}.orEmpty(),
avatarData = avatarData,
userDefinedNotificationMode = details.userDefinedNotificationMode,

View file

@ -101,7 +101,7 @@ open class RoomListRoomSummaryProvider : PreviewParameterProvider<RoomListRoomSu
userId = UserId("@bob:matrix.org"),
displayName = "Bob",
),
isDirect = true,
isDm = true,
),
aRoomListRoomSummary(
name = null,