Эх сурвалжийг харах

use new dc_send_msg_sync() api for sharing

B. Petersen 5 жил өмнө
parent
commit
a289c47033

+ 5 - 5
DcCore/DcCore/DC/Wrapper.swift

@@ -86,6 +86,10 @@ public class DcContext {
         return chatlist
     }
 
+    public func sendMsgSync(chatId: Int, msg: DcMsg) {
+        dc_send_msg_sync(contextPointer, UInt32(chatId), msg.messagePointer)
+    }
+
     public func getChatMedia(chatId: Int, messageType: Int32, messageType2: Int32, messageType3: Int32) -> [Int] {
         guard let messagesPointer = dc_get_chat_media(contextPointer, UInt32(chatId), messageType, messageType2, messageType3) else {
             return []
@@ -205,10 +209,6 @@ public class DcContext {
         dc_stop_io(contextPointer)
     }
 
-    public func performSmtpJobs() {
-        // TODO-ASYNC: call the new direct-send function
-    }
-
     public func setStockTranslation(id: Int32, localizationKey: String) {
         dc_set_stock_translation(contextPointer, UInt32(id), String.localized(localizationKey))
     }
@@ -763,7 +763,7 @@ public class DcArray {
 }
 
 public class DcMsg {
-    private var messagePointer: OpaquePointer?
+    var messagePointer: OpaquePointer?
 
     /**
         viewType: one of

+ 2 - 3
DcShare/Controller/SendingController.swift

@@ -69,10 +69,9 @@ class SendingController: UIViewController {
 
     private func sendMessage() {
         DispatchQueue.global(qos: .utility).async {
-            for message in self.dcMsgs {
-                message.sendInChat(id: self.chatId)
+            for dcMsg in self.dcMsgs {
+                self.dcContext.sendMsgSync(chatId: self.chatId, msg: dcMsg)
             }
-            self.dcContext.performSmtpJobs()
             self.delegate?.onSendingAttemptFinished()
         }
     }