Browse Source

remove unneeded check if a contact-id exist, dc_create_contact() won't create contacts twice

B. Petersen 5 years ago
parent
commit
274b7097f1

+ 2 - 5
deltachat-ios/Controller/ChatViewController.swift

@@ -496,11 +496,8 @@ class ChatViewController: MessagesViewController {
                                       preferredStyle: .actionSheet)
         alert.addAction(UIAlertAction(title: String.localized("start_chat"), style: .default, handler: { _ in
             self.dismiss(animated: true, completion: nil)
-            var contactId = Utils.getContactIdByEmail(email)
-            if contactId == nil {
-                contactId = self.dcContext.createContact(name: "", email: email)
-            }
-            let chatId = self.dcContext.createChat(contactId: contactId!)
+            let contactId = self.dcContext.createContact(name: "", email: email)
+            let chatId = self.dcContext.createChat(contactId: contactId)
             self.coordinator?.showChat(chatId: chatId)
         }))
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: { _ in

+ 0 - 5
deltachat-ios/Helper/Utils.swift

@@ -8,11 +8,6 @@ struct Utils {
         return Utils.copyAndFreeArray(inputArray: cContacts)
     }
 
-    static func getContactIdByEmail(_ address: String) -> Int? {
-        let ids = getContactIds()
-        return ids.first(where: { DcContact(id: $0).email == address })
-    }
-
     static func getBlockedContactIds() -> [Int] {
         let cBlockedContacts = dc_get_blocked_contacts(mailboxPointer)
         return Utils.copyAndFreeArray(inputArray: cBlockedContacts)