Browse Source

ask before leaving group

B. Petersen 5 years ago
parent
commit
8acafe65b7
1 changed files with 8 additions and 3 deletions
  1. 8 3
      deltachat-ios/Controller/GroupChatDetailViewController.swift

+ 8 - 3
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -91,9 +91,14 @@ class GroupChatDetailViewController: UIViewController {
 
     private func leaveGroup() {
         if let userId = currentUser?.id {
-            dc_remove_contact_from_chat(mailboxPointer, UInt32(chat.id), UInt32(userId))
-            editBarButtonItem.isEnabled = false
-            updateGroupMembers()
+            let alert = UIAlertController(title: String.localized("ask_leave_group"), message: nil, preferredStyle: .actionSheet)
+            alert.addAction(UIAlertAction(title: String.localized("menu_leave_group"), style: .destructive, handler: { _ in
+                dc_remove_contact_from_chat(mailboxPointer, UInt32(self.chat.id), UInt32(userId))
+                self.editBarButtonItem.isEnabled = false
+                self.updateGroupMembers()
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
+            present(alert, animated: true, completion: nil)
         }
     }
 }