Procházet zdrojové kódy

archive chats on swipe-to-left

B. Petersen před 5 roky
rodič
revize
ef262de173

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

@@ -178,6 +178,8 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
         }
 
         let archive = UITableViewRowAction(style: .destructive, title: String.localized("menu_archive_chat")) { [unowned self] _, _ in
+            let chatId = chatList.getChatId(index: row)
+            self.dcContext.archiveChat(chatId: chatId, archive: true)
         }
         archive.backgroundColor = UIColor.gray
 

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

@@ -13,6 +13,10 @@ class DcContext {
         dc_context_unref(contextPointer)
     }
 
+    func archiveChat(chatId: Int, archive: Bool) {
+        dc_archive_chat(self.contextPointer, UInt32(chatId), Int32(archive ? 1 : 0))
+    }
+
     func getSecurejoinQr (chatId: Int) -> String? {
         if let cString = dc_get_securejoin_qr(self.contextPointer, UInt32(chatId)) {
             return String(cString: cString)