Browse Source

add deleteChat() to DcContext

B. Petersen 5 years ago
parent
commit
3806dae7a8

+ 2 - 9
deltachat-ios/Controller/ChatListController.swift

@@ -197,9 +197,7 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
 
         return [archive, delete]
     }
-}
 
-extension ChatListController {
     private func showDeleteChatConfirmationAlert(chatId: Int) {
         let alert = UIAlertController(
             title: String.localized("ask_delete_chat_desktop"),
@@ -207,15 +205,10 @@ extension ChatListController {
             preferredStyle: .alert
         )
         alert.addAction(UIAlertAction(title: String.localized("global_menu_edit_delete_desktop"), style: .default, handler: { _ in
-            self.deleteChat(chatId: chatId)
+            self.dcContext.deleteChat(chatId: chatId)
+            self.getChatList()
         }))
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
         self.present(alert, animated: true, completion: nil)
     }
-
-    private func deleteChat(chatId: Int) {
-        dc_delete_chat(mailboxPointer, UInt32(chatId))
-        self.getChatList()
-    }
-
 }

+ 4 - 0
deltachat-ios/DC/Wrapper.swift

@@ -13,6 +13,10 @@ class DcContext {
         dc_context_unref(contextPointer)
     }
 
+    func deleteChat(chatId: Int) {
+        dc_delete_chat(self.contextPointer, UInt32(chatId))
+    }
+
     func archiveChat(chatId: Int, archive: Bool) {
         dc_archive_chat(self.contextPointer, UInt32(chatId), Int32(archive ? 1 : 0))
     }