Browse Source

move core-call to wrapper

B. Petersen 5 years ago
parent
commit
5216e157ef

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

@@ -108,11 +108,11 @@ class ChatListController: UIViewController {
     }
 
     private func getChatList() {
-        guard let chatlistPointer = dc_get_chatlist(mailboxPointer, 0, nil, 0) else {
-            fatalError("chatlistPointer was nil")
+        var gclFlags: Int32 = 0
+        if showArchive {
+            gclFlags |= DC_GCL_ARCHIVED_ONLY
         }
-        // ownership of chatlistPointer transferred here to ChatList object
-        chatList = DcChatlist(chatListPointer: chatlistPointer)
+        chatList = dcContext.getChatlist(flags: gclFlags, queryString: nil, queryId: 0)
         chatTable.reloadData()
     }
 }
@@ -170,7 +170,11 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
     func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
         let row = indexPath.row
         if let chatId = chatList?.getChatId(index: row) {
-            coordinator?.showChat(chatId: chatId)
+            if chatId==DC_CHAT_ID_ARCHIVED_LINK {
+                // TODO
+            } else {
+                coordinator?.showChat(chatId: chatId)
+            }
         }
     }
 

+ 8 - 3
deltachat-ios/DC/Wrapper.swift

@@ -13,6 +13,12 @@ class DcContext {
         dc_context_unref(contextPointer)
     }
 
+    func getChatlist(flags: Int32, queryString: String?, queryId: Int) -> DcChatlist {
+        let chatlistPointer = dc_get_chatlist(mailboxPointer, flags, queryString, UInt32(queryId))
+        let chatlist = DcChatlist(chatListPointer: chatlistPointer)
+        return chatlist
+    }
+
     func deleteChat(chatId: Int) {
         dc_delete_chat(self.contextPointer, UInt32(chatId))
     }
@@ -298,15 +304,14 @@ class DcConfig {
 }
 
 class DcChatlist {
-    private var chatListPointer: OpaquePointer
+    private var chatListPointer: OpaquePointer?
 
     var length: Int {
         return dc_chatlist_get_cnt(chatListPointer)
-        // return Int(chatListPointer.pointee.m_cnt)
     }
 
     // takes ownership of specified pointer
-    init(chatListPointer: OpaquePointer) {
+    init(chatListPointer: OpaquePointer?) {
         self.chatListPointer = chatListPointer
     }