Skip to content

Commit

Permalink
tweak confirmation message if only one chat is selected for deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Aug 11, 2024
1 parent f9fe033 commit 2cdfdb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,8 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
}

private func askToDeleteChat() {
let title = String.localized(stringID: "ask_delete_chat", parameter: 1)
let chat = dcContext.getChat(chatId: chatId)
let title = String.localizedStringWithFormat(String.localized("ask_delete_named_chat"), chat.name)
confirmationAlert(title: title, actionTitle: String.localized("delete"), actionStyle: .destructive,
actionHandler: { [weak self] _ in
guard let self else { return }
Expand Down
16 changes: 11 additions & 5 deletions deltachat-ios/Controller/ChatListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,17 @@ class ChatListViewController: UITableViewController {
if selected == 0 {
return
}
let alert = UIAlertController(
title: nil,
message: String.localized(stringID: "ask_delete_chat", parameter: selected),
preferredStyle: .safeActionSheet
)

let message: String
if selected == 1,
let chatIds = viewModel?.chatIdsFor(indexPaths: tableView.indexPathsForSelectedRows),
let chatId = chatIds.first {
message = String.localizedStringWithFormat(String.localized("ask_delete_named_chat"), dcContext.getChat(chatId: chatId).name)
} else {
message = String.localized(stringID: "ask_delete_chat", parameter: selected)
}

let alert = UIAlertController(title: nil, message: message, preferredStyle: .safeActionSheet)
alert.addAction(UIAlertAction(title: String.localized("delete"), style: .destructive, handler: { [weak self] _ in
guard let self, let viewModel = self.viewModel else { return }
viewModel.deleteChats(indexPaths: self.tableView.indexPathsForSelectedRows)
Expand Down

0 comments on commit 2cdfdb1

Please sign in to comment.