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:
parent
1a03edbe63
commit
0be7058416
47 changed files with 195 additions and 73 deletions
|
|
@ -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,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ open class RoomListRoomSummaryProvider : PreviewParameterProvider<RoomListRoomSu
|
|||
userId = UserId("@bob:matrix.org"),
|
||||
displayName = "Bob",
|
||||
),
|
||||
isDirect = true,
|
||||
isDm = true,
|
||||
),
|
||||
aRoomListRoomSummary(
|
||||
name = null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue