|
@@ -1610,29 +1610,9 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
}
|
|
}
|
|
if (idx != nil) {
|
|
if (idx != nil) {
|
|
if (chatData[CoreMessage_TMessageKey.DELETE_MESSAGE_FLAG] == "1") {
|
|
if (chatData[CoreMessage_TMessageKey.DELETE_MESSAGE_FLAG] == "1") {
|
|
- self.dataMessages[idx!]["lock"] = "1"
|
|
|
|
- self.dataMessages[idx!]["reff_id"] = ""
|
|
|
|
- let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
|
|
- let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[idx!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[idx!]["message_id"] as? String })
|
|
|
|
- if row != nil && section != nil {
|
|
|
|
- self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
|
- }
|
|
|
|
- if self.listTimerCredential[self.dataMessages[idx!]["message_id"] as! String] != nil {
|
|
|
|
- self.listTimerCredential.removeValue(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
- self.timerCredential[self.dataMessages[idx!]["message_id"] as! String]?.invalidate()
|
|
|
|
- self.timerCredential.removeValue(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
- UserDefaults.standard.removeObject(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
- }
|
|
|
|
- if self.reffId != nil && self.reffId == chatData[CoreMessage_TMessageKey.MESSAGE_ID]! {
|
|
|
|
- self.deleteReplyView()
|
|
|
|
- }
|
|
|
|
|
|
+ self.updateStatusDelete(idx: idx, chatData: chatData)
|
|
} else {
|
|
} else {
|
|
- self.dataMessages[idx!]["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
- let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
|
|
- let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[idx!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[idx!]["message_id"] as? String })
|
|
|
|
- if row != nil && section != nil {
|
|
|
|
- self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
|
- }
|
|
|
|
|
|
+ self.updateStatusMessage(idx: idx, chatData: chatData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1647,48 +1627,25 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
}
|
|
}
|
|
if (idx != nil) {
|
|
if (idx != nil) {
|
|
if (chatData[CoreMessage_TMessageKey.DELETE_MESSAGE_FLAG] == "1") {
|
|
if (chatData[CoreMessage_TMessageKey.DELETE_MESSAGE_FLAG] == "1") {
|
|
- self.dataMessages[idx!]["lock"] = "1"
|
|
|
|
- self.dataMessages[idx!]["reff_id"] = ""
|
|
|
|
- let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
|
|
- let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[idx!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[idx!]["message_id"] as? String })
|
|
|
|
- if row != nil && section != nil {
|
|
|
|
- self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
|
- }
|
|
|
|
- if self.listTimerCredential[self.dataMessages[idx!]["message_id"] as! String] != nil {
|
|
|
|
- self.listTimerCredential.removeValue(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
- self.timerCredential[self.dataMessages[idx!]["message_id"] as! String]?.invalidate()
|
|
|
|
- self.timerCredential.removeValue(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
- UserDefaults.standard.removeObject(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
- }
|
|
|
|
- if self.reffId != nil && self.reffId == chatData["message_id"]! {
|
|
|
|
- self.deleteReplyView()
|
|
|
|
- }
|
|
|
|
|
|
+ self.updateStatusDelete(idx: idx, chatData: chatData)
|
|
} else {
|
|
} else {
|
|
- self.dataMessages[idx!]["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
- let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
|
|
- let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[idx!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[idx!]["message_id"] as? String })
|
|
|
|
- if row != nil && section != nil {
|
|
|
|
- self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
|
- }
|
|
|
|
|
|
+ self.updateStatusMessage(idx: idx, chatData: chatData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- let messageId = chatData[CoreMessage_TMessageKey.MESSAGE_ID]!.split(separator: ",")[1]
|
|
|
|
- var idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String ?? "" == messageId })
|
|
|
|
- if let idxMessageIdParent = self.groupImages.firstIndex(where: { $0.value.contains(where: { $0.messageId == messageId }) }) {
|
|
|
|
- if let idxInImages = self.groupImages[idxMessageIdParent].value.firstIndex(where: { $0.messageId == messageId }) {
|
|
|
|
- self.groupImages[idxMessageIdParent].value[idxInImages].status = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
- self.groupImages[idxMessageIdParent].value[idxInImages].dataMessage["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
|
|
+ let listMessageId = chatData[CoreMessage_TMessageKey.MESSAGE_ID]!.split(separator: ",")
|
|
|
|
+ for i in 1..<listMessageId.count {
|
|
|
|
+ var idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String ?? "" == listMessageId[i] })
|
|
|
|
+ if let idxMessageIdParent = self.groupImages.firstIndex(where: { $0.value.contains(where: { $0.messageId == listMessageId[i] }) }) {
|
|
|
|
+ if let idxInImages = self.groupImages[idxMessageIdParent].value.firstIndex(where: { $0.messageId == listMessageId[i] }) {
|
|
|
|
+ self.groupImages[idxMessageIdParent].value[idxInImages].status = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
+ self.groupImages[idxMessageIdParent].value[idxInImages].dataMessage["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
+ }
|
|
|
|
+ idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == self.groupImages[idxMessageIdParent].key })
|
|
}
|
|
}
|
|
- idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == self.groupImages[idxMessageIdParent].key })
|
|
|
|
- }
|
|
|
|
- if (idx != nil) {
|
|
|
|
- self.dataMessages[idx!]["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
- let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
|
|
- let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[idx!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[idx!]["message_id"] as? String })
|
|
|
|
- if row != nil && section != nil {
|
|
|
|
- self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
|
|
|
+ if (idx != nil) {
|
|
|
|
+ self.updateStatusMessage(idx: idx, chatData: chatData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1697,6 +1654,46 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private func updateStatusDelete(idx: Int?, chatData: [String: String]) {
|
|
|
|
+ do {
|
|
|
|
+ if self.dataMessages[idx!]["lock"] as! String == "1" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self.dataMessages[idx!]["lock"] = "1"
|
|
|
|
+ self.dataMessages[idx!]["reff_id"] = ""
|
|
|
|
+ let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
|
|
+ let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[idx!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[idx!]["message_id"] as? String })
|
|
|
|
+ if row != nil && section != nil {
|
|
|
|
+ self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
|
+ }
|
|
|
|
+ if self.listTimerCredential[self.dataMessages[idx!]["message_id"] as! String] != nil {
|
|
|
|
+ self.listTimerCredential.removeValue(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
+ self.timerCredential[self.dataMessages[idx!]["message_id"] as! String]?.invalidate()
|
|
|
|
+ self.timerCredential.removeValue(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
+ UserDefaults.standard.removeObject(forKey: self.dataMessages[idx!]["message_id"] as! String)
|
|
|
|
+ }
|
|
|
|
+ if self.reffId != nil && self.reffId == chatData["message_id"]! {
|
|
|
|
+ self.deleteReplyView()
|
|
|
|
+ }
|
|
|
|
+ } catch {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private func updateStatusMessage(idx: Int?, chatData: [String: String]) {
|
|
|
|
+ do {
|
|
|
|
+ if Int(self.dataMessages[idx!]["status"] as! String)! > Int(chatData[CoreMessage_TMessageKey.STATUS]!)! {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self.dataMessages[idx!]["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
|
+ let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
|
|
+ let row = self.dataMessages.filter({ $0["chat_date"] as! String == self.dataMessages[idx!]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == self.dataMessages[idx!]["message_id"] as? String })
|
|
|
|
+ if row != nil && section != nil {
|
|
|
|
+ self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
|
+ }
|
|
|
|
+ } catch {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@objc func onTyping(notification: NSNotification) {
|
|
@objc func onTyping(notification: NSNotification) {
|
|
DispatchQueue.main.async { [self] in
|
|
DispatchQueue.main.async { [self] in
|
|
let data:[AnyHashable : Any] = notification.userInfo!
|
|
let data:[AnyHashable : Any] = notification.userInfo!
|
|
@@ -2219,7 +2216,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private func sendChat(message_scope_id:String = "3", status:String = "2", message_text:String = "", credential:String = "0", attachment_flag: String = "0", ex_blog_id: String = "", message_large_text: String = "", ex_format: String = "", image_id: String = "", audio_id: String = "", video_id: String = "", file_id: String = "", thumb_id: String = "", reff_id: String = "", read_receipts: String = "4", chat_id: String = "", is_call_center: String = "0", call_center_id: String = "", viewController: UIViewController, isAutoSendCC : Bool = false) {
|
|
|
|
|
|
+ private func sendChat(message_scope_id:String = "3", status:String = "1", message_text:String = "", credential:String = "0", attachment_flag: String = "0", ex_blog_id: String = "", message_large_text: String = "", ex_format: String = "", image_id: String = "", audio_id: String = "", video_id: String = "", file_id: String = "", thumb_id: String = "", reff_id: String = "", read_receipts: String = "4", chat_id: String = "", is_call_center: String = "0", call_center_id: String = "", viewController: UIViewController, isAutoSendCC : Bool = false) {
|
|
if viewController is EditorPersonal && file_id == "" && dataMessageForward == nil && !isAutoSendCC{
|
|
if viewController is EditorPersonal && file_id == "" && dataMessageForward == nil && !isAutoSendCC{
|
|
if ((textFieldSend.text!.trimmingCharacters(in: .whitespacesAndNewlines) == "Send message".localized() && textFieldSend.textColor == UIColor.lightGray && attachment_flag != "11") || textFieldSend.text!.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ) {
|
|
if ((textFieldSend.text!.trimmingCharacters(in: .whitespacesAndNewlines) == "Send message".localized() && textFieldSend.textColor == UIColor.lightGray && attachment_flag != "11") || textFieldSend.text!.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ) {
|
|
dismissKeyboard()
|
|
dismissKeyboard()
|
|
@@ -4660,7 +4657,9 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
statusMessage.trailingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: -8).isActive = true
|
|
statusMessage.trailingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: -8).isActive = true
|
|
statusMessage.widthAnchor.constraint(equalToConstant: 15).isActive = true
|
|
statusMessage.widthAnchor.constraint(equalToConstant: 15).isActive = true
|
|
statusMessage.heightAnchor.constraint(equalToConstant: 15).isActive = true
|
|
statusMessage.heightAnchor.constraint(equalToConstant: 15).isActive = true
|
|
- if (dataMessages[indexPath.row]["status"]! as! String == "1" || dataMessages[indexPath.row]["status"]! as! String == "2" ) {
|
|
|
|
|
|
+ if dataMessages[indexPath.row]["status"]! as! String == "1" {
|
|
|
|
+ statusMessage.image = UIImage(systemName: "clock.arrow.circlepath")!.withTintColor(UIColor.lightGray, renderingMode: .alwaysOriginal)
|
|
|
|
+ } else if (dataMessages[indexPath.row]["status"]! as! String == "2" ) {
|
|
statusMessage.image = UIImage(named: "checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.lightGray)
|
|
statusMessage.image = UIImage(named: "checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.lightGray)
|
|
} else if (dataMessages[indexPath.row]["status"]! as! String == "3") {
|
|
} else if (dataMessages[indexPath.row]["status"]! as! String == "3") {
|
|
statusMessage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.lightGray)
|
|
statusMessage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.lightGray)
|
|
@@ -5063,7 +5062,9 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
let statusInImage = UIImageView()
|
|
let statusInImage = UIImageView()
|
|
containerTimeStatus.addSubview(statusInImage)
|
|
containerTimeStatus.addSubview(statusInImage)
|
|
statusInImage.anchor(right: containerTimeStatus.rightAnchor, centerY: containerTimeStatus.centerYAnchor, width: 15, height: 15)
|
|
statusInImage.anchor(right: containerTimeStatus.rightAnchor, centerY: containerTimeStatus.centerYAnchor, width: 15, height: 15)
|
|
- if listImages[i].status == "1" || listImages[i].status == "2" {
|
|
|
|
|
|
+ if listImages[i].status == "1" {
|
|
|
|
+ statusInImage.image = UIImage(systemName: "clock.arrow.circlepath")!.withTintColor(UIColor.white, renderingMode: .alwaysOriginal)
|
|
|
|
+ } else if listImages[i].status == "2" {
|
|
statusInImage.image = UIImage(named: "checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.white)
|
|
statusInImage.image = UIImage(named: "checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.white)
|
|
} else if listImages[i].status == "3" {
|
|
} else if listImages[i].status == "3" {
|
|
statusInImage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.white)
|
|
statusInImage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.white)
|