Преглед на файлове

Merge pull request #320 from deltachat/fix-contact-requests

Fix contact requests
Jikstra преди 5 години
родител
ревизия
24ecdc3a3c
променени са 2 файла, в които са добавени 27 реда и са изтрити 6 реда
  1. 24 6
      deltachat-ios/Controller/ChatListController.swift
  2. 3 0
      deltachat-ios/Controller/MailboxViewController.swift

+ 24 - 6
deltachat-ios/Controller/ChatListController.swift

@@ -170,12 +170,30 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
 
     func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
         let row = indexPath.row
-        if let chatId = chatList?.getChatId(index: row) {
-            if chatId==DC_CHAT_ID_ARCHIVED_LINK {
-                coordinator?.showArchive()
-            } else {
-                coordinator?.showChat(chatId: chatId)
-            }
+        guard let chatList = chatList else { return }
+        let chatId = chatList.getChatId(index: row)
+        if chatId == DC_CHAT_ID_DEADDROP {
+            let msgId = chatList.getMsgId(index: row)
+            let dcMsg = DcMsg(id: msgId)
+            let dcContact = DcContact(id: dcMsg.fromContactId)
+            let title = String.localizedStringWithFormat(String.localized("ask_start_chat_with"), dcContact.nameNAddr)
+            let alert = UIAlertController(title: title, message: nil, preferredStyle: .actionSheet)
+            alert.addAction(UIAlertAction(title: String.localized("start_chat"), style: .default, handler: { _ in
+                let chat = dcMsg.createChat()
+                self.coordinator?.showChat(chatId: chat.id)
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("not_now"), style: .default, handler: { _ in
+                dcContact.marknoticed()
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("menu_block_contact"), style: .destructive, handler: { _ in
+                dcContact.block()
+            }))
+            alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel))
+            present(alert, animated: true, completion: nil)
+        } else if chatId == DC_CHAT_ID_ARCHIVED_LINK {
+            coordinator?.showArchive()
+        } else {
+            coordinator?.showChat(chatId: chatId)
         }
     }
 

+ 3 - 0
deltachat-ios/Controller/MailboxViewController.swift

@@ -52,6 +52,9 @@ class MailboxViewController: ChatViewController {
                 let chat = message.createChat()
                 self.coordinator?.showChat(chatId: chat.id)
             }))
+            alert.addAction(UIAlertAction(title: String.localized("menu_block_contact"), style: .destructive, handler: { _ in
+                dcContact.block()
+            }))
             alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel))
             present(alert, animated: true, completion: nil)
         }