Ver código fonte

update delete all grouping image

alqindiirsyam 2 anos atrás
pai
commit
12c4231fb9

+ 1 - 2
appbuilder-ios/AppBuilder/AppBuilder/SecondTabViewController.swift

@@ -480,8 +480,7 @@ class SecondTabViewController: UIViewController, UIScrollViewDelegate, UIGesture
         DispatchQueue.main.async { [self] in
             let data:[AnyHashable : Any] = notification.userInfo!
             if let dataMessage = data["message"] as? TMessage {
-                let chatData = dataMessage.mBodies
-                let indexChat = chats.firstIndex(where: { (chatData[CoreMessage_TMessageKey.MESSAGE_ID] ?? "").contains(",") ? $0.messageId == (chatData[CoreMessage_TMessageKey.MESSAGE_ID]!).components(separatedBy: ",")[1]  : $0.messageId == chatData[CoreMessage_TMessageKey.MESSAGE_ID] })
+                let indexChat = chats.firstIndex(where: { (dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)).contains(",") ? $0.messageId == (dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)).components(separatedBy: ",")[1]  : $0.messageId == dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID) })
                 if indexChat != nil {
                     tableView.beginUpdates()
                     tableView.reloadRows(at: [IndexPath(row: indexChat!, section: 0)], with: .none)

BIN
appbuilder-ios/DigiXLite/DigiXLite.xcworkspace/xcuserdata/akhmadalqindiirsyam.xcuserdatad/UserInterfaceState.xcuserstate


+ 81 - 19
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Chat/EditorPersonal.swift

@@ -34,6 +34,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     @IBOutlet weak var constraintBottomTableViewWithTextfield: NSLayoutConstraint!
     @IBOutlet weak var viewAttachment: UIStackView!
     public var dataPerson: [String: String?] = [:]
+    var dataMessagesOnGrouping: [String:[[String: Any?]]] = [:]
     var dataMessages: [[String: Any?]] = []
     var dataDates: [String] = []
     var users: [User] = []
@@ -289,7 +290,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 }
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                     let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
-                    cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white], for: .normal)
+                    cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                     if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                         self.navigationItem.rightBarButtonItems = nil
                     }
@@ -331,6 +332,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                     }
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                         let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                        cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                         if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                             self.navigationItem.rightBarButtonItems = nil
                         }
@@ -407,6 +409,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         }
                         DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                             let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                            cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                             if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                                 self.navigationItem.rightBarButtonItems = nil
                             }
@@ -479,6 +482,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         }
                         DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                             let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                            cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                             if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                                 self.navigationItem.rightBarButtonItems = nil
                             }
@@ -1125,12 +1129,15 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         }
                     }
                     if row["image_id"] != nil && !(row["image_id"] as! String).isEmpty && (row["message_text"] as! String).isEmpty && (row["reff_id"] as! String).isEmpty && (row["credential"] as! String) != "1" && (row["read_receipts"] as! String) != "8" {
-                        tempImages.append(ImageGrouping(messageId: row["message_id"] as! String, thumbId: row["thumb_id"] as! String, imageId: row["image_id"] as! String, status: row["status"] as! String, time: row["server_date"] as! String))
+                        tempImages.append(ImageGrouping(messageId: row["message_id"] as! String, thumbId: row["thumb_id"] as! String, imageId: row["image_id"] as! String, status: row["status"] as! String, time: row["server_date"] as! String, lPin: row["l_pin"] as! String))
                     } else if tempImages.count >= 4 {
                         groupImages[tempImages[0].messageId] = tempImages
+                        var tempDataOnGrouping: [[String: Any?]] =  []
                         for _ in 1..<tempImages.count {
+                            tempDataOnGrouping.insert(dataMessages.last!, at: 0)
                             dataMessages.removeLast()
                         }
+                        dataMessagesOnGrouping[tempImages[0].messageId] = tempDataOnGrouping
                         tempImages.removeAll()
                     } else if tempImages.count > 0 {
                         tempImages.removeAll()
@@ -1139,7 +1146,9 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 }
                 if tempImages.count >= 4 {
                     groupImages[tempImages[0].messageId] = tempImages
+                    var tempDataOnGrouping: [[String: Any?]] =  []
                     for _ in 1..<tempImages.count {
+                        tempDataOnGrouping.insert(dataMessages.last!, at: 0)
                         dataMessages.removeLast()
                     }
                 }
@@ -3430,6 +3439,7 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                 self.forwardSession = true
                 let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                 if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                     self.navigationItem.rightBarButtonItems = nil
                 }
@@ -3459,6 +3469,7 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                 self.copySession = true
                 let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                 if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                     self.navigationItem.rightBarButtonItems = nil
                 }
@@ -3497,6 +3508,7 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                 self.deleteSession = true
                 let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                 if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                     self.navigationItem.rightBarButtonItems = nil
                 }
@@ -3684,6 +3696,15 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             let buttonGesture = UITapGestureRecognizer(target: self, action: #selector(sessionAction))
             button.isUserInteractionEnabled = true
             button.addGestureRecognizer(buttonGesture)
+            
+            let selectedMessage = dataMessages.filter({ $0["isSelected"] as! Bool == true })
+            if selectedMessage.count > 0 {
+                for i in 0..<selectedMessage.count {
+                    if let isGroupingImages = groupImages[selectedMessage[i]["message_id"] as! String] {
+                        title.text = "\(countSelected + (isGroupingImages.count - 1)) " + "Selected".localized()
+                    }
+                }
+            }
         } else {
             buttonUp = UIButton()
             container.addSubview(buttonUp)
@@ -3798,10 +3819,15 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             self.present(contactChatNav, animated: true, completion: nil)
         } else if deleteSession {
             let dataMessages = self.dataMessages.filter({ $0["isSelected"] as! Bool == true })
-            let countSelected = dataMessages.count
+            var countSelected = dataMessages.count
             if countSelected == 0 {
                 return
             }
+            for i in 0..<countSelected {
+                if let isGroupingImages = groupImages[dataMessages[i]["message_id"] as! String] {
+                    countSelected += (isGroupingImages.count - 1)
+                }
+            }
             let alertController = LibAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
 
             if let action = self.actionDelete(for: "me", title: "Delete".localized() + " \(countSelected) " + "For Me".localized(), dataMessages: dataMessages) {
@@ -3932,26 +3958,60 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
         return UIAlertAction(title: title, style: .destructive) { [unowned self] _ in
             for i in 0..<dataMessages.count {
                 if (type == "me") {
-                    self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "1", chat: "")
-                    let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
-                    if idx != nil {
-                        self.dataMessages.remove(at: idx!)
-                        if (idx == self.dataMessages.count - 1) {
-                            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                    if let groupingImages = groupImages[dataMessages[i]["message_id"] as! String] {
+                        for i in 0..<groupingImages.count {
+                            self.deleteMessage(l_pin: groupingImages[i].lPin, message_id: groupingImages[i].messageId, scope: "3", type: "1", chat: "")
+                            let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == groupingImages[i].messageId })
+                            if idx != nil {
+                                self.dataMessages.remove(at: idx!)
+                                if (idx == self.dataMessages.count - 1) {
+                                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                                }
+                                for i in 0..<dataDates.count {
+                                    if self.dataMessages.filter({ $0["chat_date"] as! String == dataDates[i] }).count == 0 {
+                                        dataDates.remove(at: i)
+                                    }
+                                }
+                            }
                         }
-                        for i in 0..<dataDates.count {
-                            if self.dataMessages.filter({ $0["chat_date"] as! String == dataDates[i] }).count == 0 {
-                                dataDates.remove(at: i)
+                    } else {
+                        self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "1", chat: "")
+                        let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
+                        if idx != nil {
+                            self.dataMessages.remove(at: idx!)
+                            if (idx == self.dataMessages.count - 1) {
+                                NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                            }
+                            for i in 0..<dataDates.count {
+                                if self.dataMessages.filter({ $0["chat_date"] as! String == dataDates[i] }).count == 0 {
+                                    dataDates.remove(at: i)
+                                }
                             }
                         }
                     }
                 } else {
-                    self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "2", chat: "")
-                    let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
-                    if idx != nil {
-                        self.dataMessages[idx!]["lock"] = "1"
-                        self.dataMessages[idx!]["attachment_flag"] = "0"
-                        self.dataMessages[idx!]["reff_id"] = ""
+                    if let groupingImages = groupImages[dataMessages[i]["message_id"] as! String] {
+                        for i in 0..<groupingImages.count {
+                            self.deleteMessage(l_pin: groupingImages[i].lPin, message_id: groupingImages[i].messageId, scope: "3", type: "2", chat: "")
+                            let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == groupingImages[i].messageId})
+                            if idx != nil {
+                                self.dataMessages[idx!]["lock"] = "1"
+                                self.dataMessages[idx!]["attachment_flag"] = "0"
+                                self.dataMessages[idx!]["reff_id"] = ""
+                            }
+                        }
+                        if let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == groupingImages[0].messageId}) {
+                            self.dataMessages.insert(contentsOf: dataMessagesOnGrouping[groupingImages[0].messageId]!, at: idx+1)
+                            self.groupImages.removeValue(forKey: groupingImages[0].messageId)
+                        }
+                    } else {
+                        self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "2", chat: "")
+                        let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
+                        if idx != nil {
+                            self.dataMessages[idx!]["lock"] = "1"
+                            self.dataMessages[idx!]["attachment_flag"] = "0"
+                            self.dataMessages[idx!]["reff_id"] = ""
+                        }
                     }
                 }
                 if self.listTimerCredential[dataMessages[i]["message_id"] as! String] != nil {
@@ -6254,12 +6314,14 @@ public class ImageGrouping {
     public var imageId = ""
     public var status = ""
     public var time = ""
+    public var lPin = ""
     
-    public init(messageId: String, thumbId: String, imageId: String, status: String, time: String) {
+    public init(messageId: String, thumbId: String, imageId: String, status: String, time: String, lPin: String) {
         self.messageId = messageId
         self.thumbId = thumbId
         self.imageId = imageId
         self.status = status
         self.time = time
+        self.lPin = lPin
     }
 }

+ 1 - 1
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Chat/ListGroupImages.swift

@@ -34,7 +34,7 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
         tableViewImages.scrollToRow(at: IndexPath(row: imageTapped, section: 0), at: .top, animated: false)
         
         let center: NotificationCenter = NotificationCenter.default
-        center.addObserver(self, selector: #selector(onStatusChat(notification:)), name: NSNotification.Name(rawValue: Nexilis.listenerStatusChat), object: nil)
+        center.addObserver(self, selector: #selector(onStatusChat(notification:)), name: NSNotification.Name(rawValue: DigiX.listenerStatusChat), object: nil)
     }
     
     @objc func onStatusChat(notification: NSNotification) {

+ 1 - 2
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Control/ContactChatViewController.swift

@@ -318,8 +318,7 @@ class ContactChatViewController: UITableViewController {
         DispatchQueue.main.async { [self] in
             let data:[AnyHashable : Any] = notification.userInfo!
             if let dataMessage = data["message"] as? TMessage {
-                let chatData = dataMessage.mBodies
-                let indexChat = chats.firstIndex(where: { (chatData[CoreMessage_TMessageKey.MESSAGE_ID] ?? "").contains(",") ? $0.messageId == (chatData[CoreMessage_TMessageKey.MESSAGE_ID]!).components(separatedBy: ",")[1]  : $0.messageId == chatData[CoreMessage_TMessageKey.MESSAGE_ID] })
+                let indexChat = chats.firstIndex(where: { (dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)).contains(",") ? $0.messageId == (dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)).components(separatedBy: ",")[1]  : $0.messageId == dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID) })
                 if indexChat != nil {
                     tableView.beginUpdates()
                     tableView.reloadRows(at: [IndexPath(row: indexChat!, section: 0)], with: .none)

+ 82 - 19
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -34,6 +34,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     @IBOutlet weak var constraintBottomTableViewWithTextfield: NSLayoutConstraint!
     @IBOutlet weak var viewAttachment: UIStackView!
     public var dataPerson: [String: String?] = [:]
+    var dataMessagesOnGrouping: [String:[[String: Any?]]] = [:]
     var dataMessages: [[String: Any?]] = []
     var dataDates: [String] = []
     var users: [User] = []
@@ -290,7 +291,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 }
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                     let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
-                    cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white], for: .normal)
+                    cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                     if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                         self.navigationItem.rightBarButtonItems = nil
                     }
@@ -332,6 +333,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                     }
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                         let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                        cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                         if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                             self.navigationItem.rightBarButtonItems = nil
                         }
@@ -408,6 +410,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         }
                         DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                             let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                            cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                             if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                                 self.navigationItem.rightBarButtonItems = nil
                             }
@@ -480,6 +483,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         }
                         DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                             let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                            cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                             if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                                 self.navigationItem.rightBarButtonItems = nil
                             }
@@ -1126,12 +1130,15 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         }
                     }
                     if row["image_id"] != nil && !(row["image_id"] as! String).isEmpty && (row["message_text"] as! String).isEmpty && (row["reff_id"] as! String).isEmpty && (row["credential"] as! String) != "1" && (row["read_receipts"] as! String) != "8" {
-                        tempImages.append(ImageGrouping(messageId: row["message_id"] as! String, thumbId: row["thumb_id"] as! String, imageId: row["image_id"] as! String, status: row["status"] as! String, time: row["server_date"] as! String))
+                        tempImages.append(ImageGrouping(messageId: row["message_id"] as! String, thumbId: row["thumb_id"] as! String, imageId: row["image_id"] as! String, status: row["status"] as! String, time: row["server_date"] as! String, lPin: row["l_pin"] as! String))
                     } else if tempImages.count >= 4 {
                         groupImages[tempImages[0].messageId] = tempImages
+                        var tempDataOnGrouping: [[String: Any?]] =  []
                         for _ in 1..<tempImages.count {
+                            tempDataOnGrouping.insert(dataMessages.last!, at: 0)
                             dataMessages.removeLast()
                         }
+                        dataMessagesOnGrouping[tempImages[0].messageId] = tempDataOnGrouping
                         tempImages.removeAll()
                     } else if tempImages.count > 0 {
                         tempImages.removeAll()
@@ -1140,9 +1147,12 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 }
                 if tempImages.count >= 4 {
                     groupImages[tempImages[0].messageId] = tempImages
+                    var tempDataOnGrouping: [[String: Any?]] =  []
                     for _ in 1..<tempImages.count {
+                        tempDataOnGrouping.insert(dataMessages.last!, at: 0)
                         dataMessages.removeLast()
                     }
+                    dataMessagesOnGrouping[tempImages[0].messageId] = tempDataOnGrouping
                 }
                 cursorData.close()
             }
@@ -3440,6 +3450,7 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                 self.forwardSession = true
                 let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                 if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                     self.navigationItem.rightBarButtonItems = nil
                 }
@@ -3469,6 +3480,7 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                 self.copySession = true
                 let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                 if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                     self.navigationItem.rightBarButtonItems = nil
                 }
@@ -3507,6 +3519,7 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                 self.deleteSession = true
                 let cancelButton = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(self.cancelAction))
+                cancelButton.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16)], for: .normal)
                 if self.dataPerson["f_pin"] != "-999" && !self.isContactCenter {
                     self.navigationItem.rightBarButtonItems = nil
                 }
@@ -3694,6 +3707,15 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             let buttonGesture = UITapGestureRecognizer(target: self, action: #selector(sessionAction))
             button.isUserInteractionEnabled = true
             button.addGestureRecognizer(buttonGesture)
+            
+            let selectedMessage = dataMessages.filter({ $0["isSelected"] as! Bool == true })
+            if selectedMessage.count > 0 {
+                for i in 0..<selectedMessage.count {
+                    if let isGroupingImages = groupImages[selectedMessage[i]["message_id"] as! String] {
+                        title.text = "\(countSelected + (isGroupingImages.count - 1)) " + "Selected".localized()
+                    }
+                }
+            }
         } else {
             buttonUp = UIButton()
             container.addSubview(buttonUp)
@@ -3808,10 +3830,15 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
             self.present(contactChatNav, animated: true, completion: nil)
         } else if deleteSession {
             let dataMessages = self.dataMessages.filter({ $0["isSelected"] as! Bool == true })
-            let countSelected = dataMessages.count
+            var countSelected = dataMessages.count
             if countSelected == 0 {
                 return
             }
+            for i in 0..<countSelected {
+                if let isGroupingImages = groupImages[dataMessages[i]["message_id"] as! String] {
+                    countSelected += (isGroupingImages.count - 1)
+                }
+            }
             let alertController = LibAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
 
             if let action = self.actionDelete(for: "me", title: "Delete".localized() + " \(countSelected) " + "For Me".localized(), dataMessages: dataMessages) {
@@ -3942,26 +3969,60 @@ extension EditorPersonal: UIContextMenuInteractionDelegate {
         return UIAlertAction(title: title, style: .destructive) { [unowned self] _ in
             for i in 0..<dataMessages.count {
                 if (type == "me") {
-                    self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "1", chat: "")
-                    let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
-                    if idx != nil {
-                        self.dataMessages.remove(at: idx!)
-                        if (idx == self.dataMessages.count - 1) {
-                            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                    if let groupingImages = groupImages[dataMessages[i]["message_id"] as! String] {
+                        for i in 0..<groupingImages.count {
+                            self.deleteMessage(l_pin: groupingImages[i].lPin, message_id: groupingImages[i].messageId, scope: "3", type: "1", chat: "")
+                            let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == groupingImages[i].messageId })
+                            if idx != nil {
+                                self.dataMessages.remove(at: idx!)
+                                if (idx == self.dataMessages.count - 1) {
+                                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                                }
+                                for i in 0..<dataDates.count {
+                                    if self.dataMessages.filter({ $0["chat_date"] as! String == dataDates[i] }).count == 0 {
+                                        dataDates.remove(at: i)
+                                    }
+                                }
+                            }
                         }
-                        for i in 0..<dataDates.count {
-                            if self.dataMessages.filter({ $0["chat_date"] as! String == dataDates[i] }).count == 0 {
-                                dataDates.remove(at: i)
+                    } else {
+                        self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "1", chat: "")
+                        let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
+                        if idx != nil {
+                            self.dataMessages.remove(at: idx!)
+                            if (idx == self.dataMessages.count - 1) {
+                                NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                            }
+                            for i in 0..<dataDates.count {
+                                if self.dataMessages.filter({ $0["chat_date"] as! String == dataDates[i] }).count == 0 {
+                                    dataDates.remove(at: i)
+                                }
                             }
                         }
                     }
                 } else {
-                    self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "2", chat: "")
-                    let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
-                    if idx != nil {
-                        self.dataMessages[idx!]["lock"] = "1"
-                        self.dataMessages[idx!]["attachment_flag"] = "0"
-                        self.dataMessages[idx!]["reff_id"] = ""
+                    if let groupingImages = groupImages[dataMessages[i]["message_id"] as! String] {
+                        for i in 0..<groupingImages.count {
+                            self.deleteMessage(l_pin: groupingImages[i].lPin, message_id: groupingImages[i].messageId, scope: "3", type: "2", chat: "")
+                            let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == groupingImages[i].messageId})
+                            if idx != nil {
+                                self.dataMessages[idx!]["lock"] = "1"
+                                self.dataMessages[idx!]["attachment_flag"] = "0"
+                                self.dataMessages[idx!]["reff_id"] = ""
+                            }
+                        }
+                        if let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == groupingImages[0].messageId}) {
+                            self.dataMessages.insert(contentsOf: dataMessagesOnGrouping[groupingImages[0].messageId]!, at: idx+1)
+                            self.groupImages.removeValue(forKey: groupingImages[0].messageId)
+                        }
+                    } else {
+                        self.deleteMessage(l_pin: dataMessages[i]["l_pin"] as! String, message_id: dataMessages[i]["message_id"] as! String, scope: "3", type: "2", chat: "")
+                        let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == dataMessages[i]["message_id"] as? String})
+                        if idx != nil {
+                            self.dataMessages[idx!]["lock"] = "1"
+                            self.dataMessages[idx!]["attachment_flag"] = "0"
+                            self.dataMessages[idx!]["reff_id"] = ""
+                        }
                     }
                 }
                 if self.listTimerCredential[dataMessages[i]["message_id"] as! String] != nil {
@@ -6265,12 +6326,14 @@ public class ImageGrouping {
     public var imageId = ""
     public var status = ""
     public var time = ""
+    public var lPin = ""
     
-    public init(messageId: String, thumbId: String, imageId: String, status: String, time: String) {
+    public init(messageId: String, thumbId: String, imageId: String, status: String, time: String, lPin: String) {
         self.messageId = messageId
         self.thumbId = thumbId
         self.imageId = imageId
         self.status = status
         self.time = time
+        self.lPin = lPin
     }
 }

+ 1 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController.swift

@@ -318,8 +318,7 @@ class ContactChatViewController: UITableViewController {
         DispatchQueue.main.async { [self] in
             let data:[AnyHashable : Any] = notification.userInfo!
             if let dataMessage = data["message"] as? TMessage {
-                let chatData = dataMessage.mBodies
-                let indexChat = chats.firstIndex(where: { (chatData[CoreMessage_TMessageKey.MESSAGE_ID] ?? "").contains(",") ? $0.messageId == (chatData[CoreMessage_TMessageKey.MESSAGE_ID]!).components(separatedBy: ",")[1]  : $0.messageId == chatData[CoreMessage_TMessageKey.MESSAGE_ID] })
+                let indexChat = chats.firstIndex(where: { (dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)).contains(",") ? $0.messageId == (dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)).components(separatedBy: ",")[1]  : $0.messageId == dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID) })
                 if indexChat != nil {
                     tableView.beginUpdates()
                     tableView.reloadRows(at: [IndexPath(row: indexChat!, section: 0)], with: .none)