|
@@ -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
|
|
|
}
|
|
|
}
|