Explorar o código

ask before removing other member from group

B. Petersen %!s(int64=5) %!d(string=hai) anos
pai
achega
9a052b10df
Modificáronse 1 ficheiros con 15 adicións e 7 borrados
  1. 15 7
      deltachat-ios/Controller/GroupChatDetailViewController.swift

+ 15 - 7
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -235,15 +235,23 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
 
         // assigning swipe by delete to members (except for current user)
         if section == sectionMembers, row >= staticCellCountMemberSection, groupMembers[row - staticCellCountMemberSection].id != currentUser?.id {
-            let delete = UITableViewRowAction(style: .destructive, title: String.localized("global_menu_edit_delete_desktop")) { [unowned self] _, indexPath in
+            let delete = UITableViewRowAction(style: .destructive, title: String.localized("remove_desktop")) { [unowned self] _, indexPath in
 
                 let memberId = self.groupMembers[row - self.staticCellCountMemberSection].id
-                let success = dc_remove_contact_from_chat(mailboxPointer, UInt32(self.chat.id), UInt32(memberId))
-                if success == 1 {
-                    self.groupMembers.remove(at: row - self.staticCellCountMemberSection)
-                    tableView.deleteRows(at: [indexPath], with: .fade)
-                    tableView.reloadData()
-                }
+                let contact = DcContact(id: memberId)
+
+                let title = String.localizedStringWithFormat(String.localized("ask_remove_members"), contact.nameNAddr)
+                let alert = UIAlertController(title: title, message: nil, preferredStyle: .actionSheet)
+                alert.addAction(UIAlertAction(title: String.localized("remove_desktop"), style: .destructive, handler: { _ in
+                    let success = dc_remove_contact_from_chat(mailboxPointer, UInt32(self.chat.id), UInt32(memberId))
+                    if success == 1 {
+                        self.groupMembers.remove(at: row - self.staticCellCountMemberSection)
+                        tableView.deleteRows(at: [indexPath], with: .fade)
+                        tableView.reloadData()
+                    }
+                }))
+                alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+                self.present(alert, animated: true, completion: nil)
             }
             delete.backgroundColor = UIColor.red
             return [delete]