Browse Source

don't show '... and on server' as deletion confirmation if message to be deleted is a device message

cyberta 3 years ago
parent
commit
2220222d05

+ 4 - 1
deltachat-ios/Chat/ChatViewController.swift

@@ -1095,7 +1095,10 @@ class ChatViewController: UITableViewController {
     }
 
     private func askToDeleteMessages(ids: [Int]) {
-        let title = String.localized(stringID: "ask_delete_messages", count: ids.count)
+        let chat = dcContext.getChat(chatId: chatId)
+        let title = chat.isDeviceTalk ?
+            String.localized(stringID: "ask_delete_messages_simple", count: ids.count) :
+            String.localized(stringID: "ask_delete_messages", count: ids.count)
         confirmationAlert(title: title, actionTitle: String.localized("delete"), actionStyle: .destructive,
                           actionHandler: { _ in
                             self.dcContext.deleteMessages(msgIds: ids)

+ 2 - 2
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -463,13 +463,13 @@ class ContactDetailViewController: UITableViewController {
 
     private func showDocuments() {
         let messageIds: [Int] = viewModel.documentItemMessageIds.reversed()
-        let fileGalleryController = DocumentGalleryController(context: viewModel.context, fileMessageIds: messageIds)
+        let fileGalleryController = DocumentGalleryController(context: viewModel.context, chatId: viewModel.chatId, fileMessageIds: messageIds)
         navigationController?.pushViewController(fileGalleryController, animated: true)
     }
 
     private func showGallery() {
         let messageIds: [Int] = viewModel.galleryItemMessageIds.reversed()
-        let galleryController = GalleryViewController(context: viewModel.context, mediaMessageIds: messageIds)
+        let galleryController = GalleryViewController(context: viewModel.context, chatId: viewModel.chatId, mediaMessageIds: messageIds)
         navigationController?.pushViewController(galleryController, animated: true)
     }
 

+ 7 - 2
deltachat-ios/Controller/DocumentGalleryController.swift

@@ -5,6 +5,7 @@ class DocumentGalleryController: UIViewController {
 
     private var fileMessageIds: [Int]
     private let dcContext: DcContext
+    private let chatId: Int
 
     private lazy var tableView: UITableView = {
         let table = UITableView(frame: .zero, style: .grouped)
@@ -46,9 +47,10 @@ class DocumentGalleryController: UIViewController {
         return menu
     }()
 
-    init(context: DcContext, fileMessageIds: [Int]) {
+    init(context: DcContext, chatId: Int, fileMessageIds: [Int]) {
         self.dcContext = context
         self.fileMessageIds = fileMessageIds
+        self.chatId = chatId
         super.init(nibName: nil, bundle: nil)
         self.title = String.localized("files")
     }
@@ -89,7 +91,10 @@ class DocumentGalleryController: UIViewController {
 
     // MARK: - actions
     private func askToDeleteItem(at indexPath: IndexPath) {
-        let title = String.localized(stringID: "ask_delete_messages", count: 1)
+        let chat = dcContext.getChat(chatId: chatId)
+        let title = chat.isDeviceTalk ?
+            String.localized(stringID: "ask_delete_messages_simple", count: 1) :
+            String.localized(stringID: "ask_delete_messages", count: 1)
         let alertController =  UIAlertController(title: title, message: nil, preferredStyle: .safeActionSheet)
         let okAction = UIAlertAction(title: String.localized("delete"), style: .destructive, handler: { [weak self] _ in
             self?.deleteItem(at: indexPath)

+ 7 - 2
deltachat-ios/Controller/GalleryViewController.swift

@@ -6,6 +6,7 @@ class GalleryViewController: UIViewController {
 
     private let dcContext: DcContext
     // MARK: - data
+    private let chatId: Int
     private var mediaMessageIds: [Int]
     private var items: [Int: GalleryItem] = [:]
 
@@ -71,8 +72,9 @@ class GalleryViewController: UIViewController {
         return config
     }()
 
-    init(context: DcContext, mediaMessageIds: [Int]) {
+    init(context: DcContext, chatId: Int, mediaMessageIds: [Int]) {
         self.dcContext = context
+        self.chatId = chatId
         self.mediaMessageIds = mediaMessageIds
         super.init(nibName: nil, bundle: nil)
     }
@@ -134,7 +136,10 @@ class GalleryViewController: UIViewController {
 
     // MARK: - actions
     private func askToDeleteItem(at indexPath: IndexPath) {
-        let title = String.localized(stringID: "ask_delete_messages", count: 1)
+        let chat = dcContext.getChat(chatId: chatId)
+        let title = chat.isDeviceTalk ?
+            String.localized(stringID: "ask_delete_messages_simple", count: 1) :
+            String.localized(stringID: "ask_delete_messages", count: 1)
         let alertController =  UIAlertController(title: title, message: nil, preferredStyle: .safeActionSheet)
         let okAction = UIAlertAction(title: String.localized("delete"), style: .destructive, handler: { [weak self] _ in
             self?.deleteItem(at: indexPath)

+ 2 - 2
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -379,12 +379,12 @@ class GroupChatDetailViewController: UIViewController {
 
     private func showDocuments() {
         let messageIds: [Int] = documentItemMessageIds.reversed()
-        let fileGalleryController = DocumentGalleryController(context: dcContext, fileMessageIds: messageIds)
+        let fileGalleryController = DocumentGalleryController(context: dcContext, chatId: chatId, fileMessageIds: messageIds)
         navigationController?.pushViewController(fileGalleryController, animated: true)    }
 
     private func showGallery() {
         let messageIds: [Int] = galleryItemMessageIds.reversed()
-        let galleryController = GalleryViewController(context: dcContext, mediaMessageIds: messageIds)
+        let galleryController = GalleryViewController(context: dcContext, chatId: chatId, mediaMessageIds: messageIds)
         navigationController?.pushViewController(galleryController, animated: true)
     }