瀏覽代碼

ask to delete chat for group chat contact requests

cyberta 4 年之前
父節點
當前提交
422961d0bc
共有 2 個文件被更改,包括 29 次插入8 次删除
  1. 18 2
      deltachat-ios/Chat/ChatViewController.swift
  2. 11 6
      deltachat-ios/Chat/Views/ChatContactRequestBar.swift

+ 18 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -1053,6 +1053,18 @@ class ChatViewController: UITableViewController {
             }))
         present(alert, animated: true, completion: nil)
     }
+    
+    private func askToDeleteChat() {
+        let title = String.localized(stringID: "ask_delete_chat", count: 1)
+        confirmationAlert(title: title, actionTitle: String.localized("delete"), actionStyle: .destructive,
+                          actionHandler: { [weak self] _ in
+                            guard let self = self else { return }
+                            self.dcContext.deleteChat(chatId: self.chatId)
+
+                            self.navigationController?.popViewController(animated: true)
+                          })
+    }
+    
 
     private func askToChatWith(email: String) {
         let contactId = self.dcContext.createContact(name: "", email: email)
@@ -1690,15 +1702,19 @@ extension ChatViewController: ChatEditingDelegate {
 
 // MARK: - ChatContactRequestBar
 extension ChatViewController: ChatContactRequestDelegate {
-    func onAcceptPressed() {
+    func onAcceptRequest() {
         dcContext.acceptChat(chatId: chatId)
         configureUIForWriting()
     }
 
-    func onBlockPressed() {
+    func onBlockRequest() {
         dcContext.blockChat(chatId: chatId)
         self.navigationController?.popViewController(animated: true)
     }
+    
+    func onDeleteRequest() {
+        self.askToDeleteChat()
+    }
 }
 
 // MARK: - QLPreviewControllerDelegate

+ 11 - 6
deltachat-ios/Chat/Views/ChatContactRequestBar.swift

@@ -3,8 +3,9 @@ import InputBarAccessoryView
 import DcCore
 
 public protocol ChatContactRequestDelegate: class {
-    func onAcceptPressed()
-    func onBlockPressed()
+    func onAcceptRequest()
+    func onBlockRequest()
+    func onDeleteRequest()
 }
 
 public class ChatContactRequestBar: UIView, InputItem {
@@ -70,17 +71,21 @@ public class ChatContactRequestBar: UIView, InputItem {
         let acceptGestureListener = UITapGestureRecognizer(target: self, action: #selector(onAcceptPressed))
         acceptButton.addGestureRecognizer(acceptGestureListener)
 
-        let blockGestureListener = UITapGestureRecognizer(target: self, action: #selector(onBlockPressed))
+        let blockGestureListener = UITapGestureRecognizer(target: self, action: #selector(onRejectPressed))
         blockButton.addGestureRecognizer(blockGestureListener)
 
     }
 
     @objc func onAcceptPressed() {
-        delegate?.onAcceptPressed()
+        delegate?.onAcceptRequest()
     }
 
-    @objc func onBlockPressed() {
-        delegate?.onBlockPressed()
+    @objc func onRejectPressed() {
+        if isGroupRequest {
+            delegate?.onDeleteRequest()
+        } else {
+            delegate?.onBlockRequest()
+        }
     }
 
     public override var intrinsicContentSize: CGSize {