Skip to content

Commit

Permalink
delete messages for all
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Feb 25, 2025
1 parent 38fc2c1 commit 403c7e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
21 changes: 16 additions & 5 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1289,17 +1289,28 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate {
}

private func askToDeleteMessages(ids: [Int]) {
let title = String.localized(stringID: "ask_delete_messages_simple", parameter: ids.count)
confirmationAlert(title: title, actionTitle: String.localized("delete"), actionStyle: .destructive,
actionHandler: { _ in
self.dcContext.deleteMessages(msgIds: ids)
func deleteInUi(ids: [Int]) {
if #available(iOS 17.0, *) {
ids.forEach { UserDefaults.shared?.removeWebxdcFromHomescreen(accountId: self.dcContext.id, messageId: $0) }
}
if self.tableView.isEditing {
self.setEditing(isEditing: false)
}
})
}

let alert = UIAlertController(title: String.localized(stringID: "ask_delete_messages_simple", parameter: ids.count), message: nil, preferredStyle: .safeActionSheet)
alert.addAction(UIAlertAction(title: "Delete for Me", style: .destructive, handler: { _ in
self.dcContext.deleteMessages(msgIds: ids)
deleteInUi(ids: ids)
}))
alert.addAction(UIAlertAction(title: "Delete for Everyone", style: .destructive, handler: { _ in
self.dcContext.sendDeleteRequest(msgIds: ids)
deleteInUi(ids: ids)
}))
alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: { _ in
self.dismiss(animated: true, completion: nil)
}))
present(alert, animated: true, completion: nil)
}

private func askToForwardMessage() {
Expand Down
4 changes: 4 additions & 0 deletions deltachat-ios/DC/DcContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class DcContext {
dc_send_edit_request(contextPointer, UInt32(msgId), newText)

Check failure on line 66 in deltachat-ios/DC/DcContext.swift

View workflow job for this annotation

GitHub Actions / build

cannot find 'dc_send_edit_request' in scope
}

public func sendDeleteRequest(msgIds: [Int]) {
dc_send_delete_request(contextPointer, msgIds.compactMap { UInt32($0) }, Int32(msgIds.count))

Check failure on line 70 in deltachat-ios/DC/DcContext.swift

View workflow job for this annotation

GitHub Actions / build

cannot find 'dc_send_delete_request' in scope
}

public func downloadFullMessage(id: Int) {
dc_download_full_msg(contextPointer, Int32(id))
}
Expand Down

0 comments on commit 403c7e1

Please sign in to comment.