Change Leave Room to Leave Conversation for DMs (#2354)

This commit is contained in:
Mauro 2024-01-18 16:48:11 +01:00 committed by GitHub
parent 3ae33f1309
commit 74ec4f09ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 25 additions and 7 deletions

View File

@ -56,6 +56,7 @@
"action_join" = "Join";
"action_learn_more" = "Learn more";
"action_leave" = "Leave";
"action_leave_conversation" = "Leave conversation";
"action_leave_room" = "Leave room";
"action_manage_account" = "Manage account";
"action_manage_devices" = "Manage devices";
@ -228,6 +229,7 @@
"error_unknown" = "Sorry, an error occurred";
"invite_friends_rich_title" = "🔐️ Join me on %1$@";
"invite_friends_text" = "Hey, talk to me on %1$@: %2$@";
"leave_conversation_alert_subtitle" = "Are you sure that you want to leave this conversation? This conversation is not public and you won't be able to rejoin without an invite.";
"leave_room_alert_empty_subtitle" = "Are you sure that you want to leave this room? You're the only person here. If you leave, no one will be able to join in the future, including you.";
"leave_room_alert_private_subtitle" = "Are you sure that you want to leave this room? This room is not public and you won't be able to rejoin without an invite.";
"leave_room_alert_subtitle" = "Are you sure that you want to leave the room?";
@ -679,6 +681,7 @@
"screen_dm_details_unblock_user" = "Unblock user";
"screen_login_subtitle" = "Matrix is an open network for secure, decentralised communication.";
"screen_report_content_block_user" = "Block user";
"screen_room_details_leave_conversation_title" = "Leave conversation";
"screen_room_details_leave_room_title" = "Leave room";
"screen_room_details_security_title" = "Security";
"screen_room_details_topic_title" = "Topic";

View File

@ -146,6 +146,8 @@ public enum L10n {
public static var actionLearnMore: String { return L10n.tr("Localizable", "action_learn_more") }
/// Leave
public static var actionLeave: String { return L10n.tr("Localizable", "action_leave") }
/// Leave conversation
public static var actionLeaveConversation: String { return L10n.tr("Localizable", "action_leave_conversation") }
/// Leave room
public static var actionLeaveRoom: String { return L10n.tr("Localizable", "action_leave_room") }
/// Manage account
@ -524,6 +526,8 @@ public enum L10n {
public static func inviteFriendsText(_ p1: Any, _ p2: Any) -> String {
return L10n.tr("Localizable", "invite_friends_text", String(describing: p1), String(describing: p2))
}
/// Are you sure that you want to leave this conversation? This conversation is not public and you won't be able to rejoin without an invite.
public static var leaveConversationAlertSubtitle: String { return L10n.tr("Localizable", "leave_conversation_alert_subtitle") }
/// Are you sure that you want to leave this room? You're the only person here. If you leave, no one will be able to join in the future, including you.
public static var leaveRoomAlertEmptySubtitle: String { return L10n.tr("Localizable", "leave_room_alert_empty_subtitle") }
/// Are you sure that you want to leave this room? This room is not public and you won't be able to rejoin without an invite.
@ -1188,6 +1192,8 @@ public enum L10n {
public static var screenRoomDetailsErrorUnmuting: String { return L10n.tr("Localizable", "screen_room_details_error_unmuting") }
/// Invite people
public static var screenRoomDetailsInvitePeopleTitle: String { return L10n.tr("Localizable", "screen_room_details_invite_people_title") }
/// Leave conversation
public static var screenRoomDetailsLeaveConversationTitle: String { return L10n.tr("Localizable", "screen_room_details_leave_conversation_title") }
/// Leave room
public static var screenRoomDetailsLeaveRoomTitle: String { return L10n.tr("Localizable", "screen_room_details_leave_room_title") }
/// Custom

View File

@ -331,9 +331,9 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
}
if room.isPublic {
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomId, state: .public)
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomId, isDM: room.isEncryptedOneToOneRoom, state: .public)
} else {
state.bindings.leaveRoomAlertItem = room.joinedMembersCount > 1 ? LeaveRoomAlertItem(roomId: roomId, state: .private) : LeaveRoomAlertItem(roomId: roomId, state: .empty)
state.bindings.leaveRoomAlertItem = room.joinedMembersCount > 1 ? LeaveRoomAlertItem(roomId: roomId, isDM: room.isEncryptedOneToOneRoom, state: .private) : LeaveRoomAlertItem(roomId: roomId, isDM: room.isEncryptedOneToOneRoom, state: .empty)
}
}
}

View File

@ -147,15 +147,19 @@ struct LeaveRoomAlertItem: AlertProtocol {
}
let roomId: String
let isDM: Bool
let state: RoomState
let title = L10n.actionLeaveRoom
let confirmationTitle = L10n.actionLeave
let cancelTitle = L10n.actionCancel
var title: String {
isDM ? L10n.actionLeaveConversation : L10n.actionLeaveRoom
}
var subtitle: String {
switch state {
case .empty: return L10n.leaveRoomAlertEmptySubtitle
case .private: return L10n.leaveRoomAlertPrivateSubtitle
case .private: return isDM ? L10n.leaveConversationAlertSubtitle : L10n.leaveRoomAlertPrivateSubtitle
case .public: return L10n.leaveRoomAlertSubtitle
}
}

View File

@ -90,10 +90,10 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
actionsSubject.send(.requestInvitePeoplePresentation)
case .processTapLeave:
guard state.joinedMembersCount > 1 else {
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, state: .empty)
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, isDM: roomProxy.isEncryptedOneToOneRoom, state: .empty)
return
}
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, state: roomProxy.isPublic ? .public : .private)
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomId: roomProxy.id, isDM: roomProxy.isEncryptedOneToOneRoom, state: roomProxy.isPublic ? .public : .private)
case .confirmLeave:
Task { await leaveRoom() }
case .processTapIgnore:

View File

@ -220,10 +220,14 @@ struct RoomDetailsScreen: View {
}
}
}
private var leaveRoomTitle: String {
context.viewState.dmRecipient == nil ? L10n.screenRoomDetailsLeaveRoomTitle : L10n.screenRoomDetailsLeaveConversationTitle
}
private var leaveRoomSection: some View {
Section {
ListRow(label: .action(title: L10n.actionLeaveRoom,
ListRow(label: .action(title: leaveRoomTitle,
icon: \.leave,
role: .destructive),
kind: .button { context.send(viewAction: .processTapLeave) })

1
changelog.d/2330.change Normal file
View File

@ -0,0 +1 @@
Change Leave Room to Leave Conversation for DMs