Bläddra i källkod

moved getMessageIds from DcUtils to DcContext

nayooti 5 år sedan
förälder
incheckning
b7535d0090

+ 12 - 0
DcCore/DcCore/DC/Wrapper.swift

@@ -29,6 +29,18 @@ public class DcContext {
         return .dcContext
     }
 
+    public func getMessageIds(chatId: Int, count: Int, from: Int?) -> [Int] {
+		let cMessageIds = getChatMessages(chatId: chatId)
+
+        let ids: [Int]
+        if let from = from {
+            ids = DcUtils.copyAndFreeArrayWithOffset(inputArray: cMessageIds, len: count, skipEnd: from)
+        } else {
+            ids = DcUtils.copyAndFreeArrayWithLen(inputArray: cMessageIds, len: count)
+        }
+        return ids
+    }
+
     public func createContact(name: String, email: String) -> Int {
         return Int(dc_create_contact(contextPointer, name, email))
     }

+ 0 - 12
DcCore/DcCore/Helper/DcUtils.swift

@@ -3,18 +3,6 @@ import UIKit
 
 public struct DcUtils {
 
-    public static func getMessageIds(chatId: Int, count: Int, from: Int?) -> [Int] {
-        let cMessageIds = DcContext.shared.getChatMessages(chatId: chatId)
-
-        let ids: [Int]
-        if let from = from {
-            ids = DcUtils.copyAndFreeArrayWithOffset(inputArray: cMessageIds, len: count, skipEnd: from)
-        } else {
-            ids = DcUtils.copyAndFreeArrayWithLen(inputArray: cMessageIds, len: count)
-        }
-        return ids
-    }
-
     static func copyAndFreeArray(inputArray: OpaquePointer?) -> [Int] {
         var acc: [Int] = []
         let len = dc_array_get_cnt(inputArray)

+ 1 - 1
deltachat-ios/Controller/ChatViewController.swift

@@ -355,7 +355,7 @@ class ChatViewController: MessagesViewController {
     }
 
     private func getMessageIds(_ count: Int, from: Int? = nil) -> [DcMsg] {
-        let ids = DcUtils.getMessageIds(chatId: chatId, count: count, from: from)
+        let ids = dcContext.getMessageIds(chatId: chatId, count: count, from: from)
         let markIds: [UInt32] = ids.map { UInt32($0) }
         dcContext.markSeenMessages(messageIds: markIds, count: ids.count)