Replace 'leave room' text with 'leave conversation' for DMs (#2231)

* Replace 'leave room' text with 'leave conversation' for DMs

* Add `isDm` property to both `RoomSummary` and `RoomListRoomSummary`

* Remove redundant `leave_conversation_alert_subtitle_*` texts

* Fix maestro flow

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
This commit is contained in:
Jorge Martin Espinosa 2024-01-16 15:49:44 +01:00 committed by GitHub
parent d7dcd7aa34
commit 27f55c0bc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 115 additions and 19 deletions

View file

@ -95,7 +95,14 @@ private fun RoomListModalBottomSheetContent(
style = ListItemStyle.Primary,
)
ListItem(
headlineContent = { Text(text = stringResource(id = CommonStrings.action_leave_room)) },
headlineContent = {
val leaveText = stringResource(id = if (contextMenu.isDm) {
CommonStrings.action_leave_conversation
} else {
CommonStrings.action_leave_room
})
Text(text = leaveText)
},
modifier = Modifier.clickable { onLeaveRoomClicked(contextMenu.roomId) },
leadingContent = ListItemContent.Icon(
iconSource = IconSource.Vector(
@ -117,7 +124,22 @@ internal fun RoomListModalBottomSheetContentPreview() = ElementPreview {
RoomListModalBottomSheetContent(
contextMenu = RoomListState.ContextMenu.Shown(
roomId = RoomId(value = "!aRoom:aDomain"),
roomName = "aRoom"
roomName = "aRoom",
isDm = false,
),
onRoomSettingsClicked = {},
onLeaveRoomClicked = {}
)
}
@PreviewsDayNight
@Composable
internal fun RoomListModalBottomSheetContentForDmPreview() = ElementPreview {
RoomListModalBottomSheetContent(
contextMenu = RoomListState.ContextMenu.Shown(
roomId = RoomId(value = "!aRoom:aDomain"),
roomName = "aRoom",
isDm = true,
),
onRoomSettingsClicked = {},
onLeaveRoomClicked = {}

View file

@ -119,7 +119,8 @@ class RoomListPresenter @Inject constructor(
is RoomListEvents.ShowContextMenu -> {
contextMenu = RoomListState.ContextMenu.Shown(
roomId = event.roomListRoomSummary.roomId,
roomName = event.roomListRoomSummary.name
roomName = event.roomListRoomSummary.name,
isDm = event.roomListRoomSummary.isDm,
)
}
is RoomListEvents.HideContextMenu -> contextMenu = RoomListState.ContextMenu.Hidden

View file

@ -46,6 +46,7 @@ data class RoomListState(
data class Shown(
val roomId: RoomId,
val roomName: String,
val isDm: Boolean,
) : ContextMenu
}
}

View file

@ -44,7 +44,8 @@ open class RoomListStateProvider : PreviewParameterProvider<RoomListState> {
aRoomListState().copy(
contextMenu = RoomListState.ContextMenu.Shown(
roomId = RoomId("!aRoom:aDomain"),
roomName = "A nice room name"
roomName = "A nice room name",
isDm = false,
)
),
aRoomListState().copy(displayRecoveryKeyPrompt = true),

View file

@ -162,6 +162,7 @@ class RoomListDataSource @Inject constructor(
avatarData = avatarData,
notificationMode = roomSummary.details.notificationMode,
hasOngoingCall = roomSummary.details.hasOngoingCall,
isDm = roomSummary.details.isDm,
)
}
null -> null

View file

@ -34,4 +34,5 @@ data class RoomListRoomSummary(
val isPlaceholder: Boolean = false,
val notificationMode: RoomNotificationMode? = null,
val hasOngoingCall: Boolean = false,
val isDm: Boolean = false,
)

View file

@ -321,7 +321,7 @@ class RoomListPresenterTests {
val shownState = awaitItem()
assertThat(shownState.contextMenu)
.isEqualTo(RoomListState.ContextMenu.Shown(summary.roomId, summary.name))
.isEqualTo(RoomListState.ContextMenu.Shown(summary.roomId, summary.name, false))
scope.cancel()
}
}
@ -341,7 +341,7 @@ class RoomListPresenterTests {
val shownState = awaitItem()
assertThat(shownState.contextMenu)
.isEqualTo(RoomListState.ContextMenu.Shown(summary.roomId, summary.name))
.isEqualTo(RoomListState.ContextMenu.Shown(summary.roomId, summary.name, false))
shownState.eventSink(RoomListEvents.HideContextMenu)
val hiddenState = awaitItem()