cyberta 4 жил өмнө
parent
commit
ced265eafa

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

@@ -27,9 +27,9 @@ public class DcContext {
         return .dcContext
     }
 
-    public func getMessageIds(chatId: Int, count: Int? = nil, from: Int? = nil) -> [Int] {
+    public func getMessageIds(chatId: Int, count: Int? = nil, from: Int? = nil, flags: Int32 = 0) -> [Int] {
         let start = CFAbsoluteTimeGetCurrent()
-        let cMessageIds = getChatMessages(chatId: chatId)
+        let cMessageIds = getChatMessages(chatId: chatId, flags: flags)
         let diff = CFAbsoluteTimeGetCurrent() - start
         logger?.info("⏰ getMessageIds: \(diff) s")
 
@@ -255,8 +255,8 @@ public class DcContext {
         }
     }
 
-    private func getChatMessages(chatId: Int) -> OpaquePointer {
-        return dc_get_chat_msgs(contextPointer, UInt32(chatId), 0, 0)
+    private func getChatMessages(chatId: Int, flags: Int32) -> OpaquePointer {
+        return dc_get_chat_msgs(contextPointer, UInt32(chatId), UInt32(flags), 0)
     }
     
     public func getMsgInfo(msgId: Int) -> String {

+ 6 - 0
DcCore/DcCore/Helper/DateUtils.swift

@@ -23,6 +23,12 @@ public class DateUtils {
         formatter.locale = .current
         return formatter
     }
+    
+    public static func getDateString(date: Date) -> String {
+        let formatter = getLocalDateFormatter()
+        formatter.dateStyle = .full
+        return formatter.string(from: date)
+    }
 
     public static func getExtendedRelativeTimeSpanString(timeStamp: Double) -> String {
         let seconds = getRelativeTimeInSeconds(timeStamp: timeStamp)

+ 10 - 3
deltachat-ios/Chat/ChatViewController.swift

@@ -509,11 +509,18 @@ class ChatViewController: UITableViewController {
         _ = handleUIMenu()
 
         let id = messageIds[indexPath.row]
+        if id == DC_MSG_ID_DAYMARKER, messageIds.count > indexPath.row + 1 {
+            let nextMessageId = messageIds[indexPath.row + 1]
+            let nextMessage = DcMsg(id: nextMessageId)
+            let cell = tableView.dequeueReusableCell(withIdentifier: "info", for: indexPath) as? InfoMessageCell ?? InfoMessageCell()
+            cell.update(text: DateUtils.getDateString(date: nextMessage.sentDate))
+            return cell
+        }
+        
         let message = DcMsg(id: id)
-
         if message.isInfo {
             let cell = tableView.dequeueReusableCell(withIdentifier: "info", for: indexPath) as? InfoMessageCell ?? InfoMessageCell()
-            cell.update(msg: message)
+            cell.update(text: message.text)
             return cell
         }
 
@@ -791,7 +798,7 @@ class ChatViewController: UITableViewController {
     }
     
     private func getMessageIds() -> [Int] {
-        return dcContext.getMessageIds(chatId: chatId)
+        return dcContext.getMessageIds(chatId: chatId, flags: DC_GCM_ADDDAYMARKER)
     }
 
     @objc private func saveDraft() {

+ 2 - 2
deltachat-ios/Chat/Views/Cells/InfoMessageCell.swift

@@ -51,8 +51,8 @@ class InfoMessageCell: UITableViewCell {
         selectionStyle = .none
     }
 
-    func update(msg: DcMsg) {
-        messageLabel.text = msg.text
+    func update(text: String?) {
+        messageLabel.text = text
         var corners: UIRectCorner = []
         corners.formUnion(.topLeft)
         corners.formUnion(.bottomLeft)