Skip to content

Commit

Permalink
clear chat: do not count or delete daymarker
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Oct 16, 2024
1 parent c2ba4cf commit 889a17a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deltachat-ios/Controller/ContactDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions deltachat-ios/DC/DcContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 889a17a

Please sign in to comment.