From 889a17a07fadb2be76a0cfc092ac5c367192c3c9 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 16 Oct 2024 16:29:00 +0200 Subject: [PATCH] clear chat: do not count or delete daymarker --- deltachat-ios/Chat/ChatViewController.swift | 4 ++-- deltachat-ios/Controller/ContactDetailViewController.swift | 2 +- deltachat-ios/Controller/GroupChatDetailViewController.swift | 2 +- deltachat-ios/DC/DcContext.swift | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deltachat-ios/Chat/ChatViewController.swift b/deltachat-ios/Chat/ChatViewController.swift index fd4dda471..134ae50d8 100644 --- a/deltachat-ios/Chat/ChatViewController.swift +++ b/deltachat-ios/Chat/ChatViewController.swift @@ -938,7 +938,7 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate { guard !tableView.isEditing else { return refreshMessagesAfterEditing = true } - messageIds = dcContext.getChatMsgs(chatId: chatId).reversed() + messageIds = dcContext.getChatMsgs(chatId: chatId, flags: DC_GCM_ADDDAYMARKER).reversed() reloadData() showEmptyStateView(messageIds.isEmpty) } @@ -953,7 +953,7 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate { private func loadMessages() { // update message ids - var msgIds = dcContext.getChatMsgs(chatId: chatId) + var msgIds = dcContext.getChatMsgs(chatId: chatId, flags: DC_GCM_ADDDAYMARKER) let freshMsgsCount = self.dcContext.getUnreadMessages(chatId: self.chatId) if freshMsgsCount > 0 && msgIds.count >= freshMsgsCount { let index = msgIds.count - freshMsgsCount diff --git a/deltachat-ios/Controller/ContactDetailViewController.swift b/deltachat-ios/Controller/ContactDetailViewController.swift index 4ccb9d33f..94701e034 100644 --- a/deltachat-ios/Controller/ContactDetailViewController.swift +++ b/deltachat-ios/Controller/ContactDetailViewController.swift @@ -440,7 +440,7 @@ class ContactDetailViewController: UITableViewController { // MARK: alerts private func showClearChatConfirmationAlert() { - let msgIds = viewModel.context.getChatMsgs(chatId: viewModel.chatId) + let msgIds = viewModel.context.getChatMsgs(chatId: viewModel.chatId, flags: 0) if !msgIds.isEmpty { let alert = UIAlertController( title: nil, diff --git a/deltachat-ios/Controller/GroupChatDetailViewController.swift b/deltachat-ios/Controller/GroupChatDetailViewController.swift index c6ac2e7e2..00c82f4a3 100644 --- a/deltachat-ios/Controller/GroupChatDetailViewController.swift +++ b/deltachat-ios/Controller/GroupChatDetailViewController.swift @@ -669,7 +669,7 @@ extension GroupChatDetailViewController { } private func showClearChatConfirmationAlert() { - let msgIds = dcContext.getChatMsgs(chatId: chatId) + let msgIds = dcContext.getChatMsgs(chatId: chatId, flags: 0) if !msgIds.isEmpty { let alert = UIAlertController( title: nil, diff --git a/deltachat-ios/DC/DcContext.swift b/deltachat-ios/DC/DcContext.swift index 29d7d7fff..8f69a4351 100644 --- a/deltachat-ios/DC/DcContext.swift +++ b/deltachat-ios/DC/DcContext.swift @@ -102,9 +102,9 @@ public class DcContext { return Int(dc_send_videochat_invitation(contextPointer, UInt32(chatId))) } - public func getChatMsgs(chatId: Int) -> [Int] { + public func getChatMsgs(chatId: Int, flags: Int32) -> [Int] { let start = CFAbsoluteTimeGetCurrent() - let cMessageIds = dc_get_chat_msgs(contextPointer, UInt32(chatId), UInt32(DC_GCM_ADDDAYMARKER), 0) + let cMessageIds = dc_get_chat_msgs(contextPointer, UInt32(chatId), UInt32(flags), 0) let diff = CFAbsoluteTimeGetCurrent() - start logger.info("⏰ getChatMsgs: \(diff) s")