|
@@ -372,7 +372,7 @@ public class EditorGroup: UIViewController {
|
|
|
row["video_id"] = cursorData.string(forColumnIndex: 8)
|
|
|
row["image_id"] = cursorData.string(forColumnIndex: 9)
|
|
|
row["thumb_id"] = cursorData.string(forColumnIndex: 10)
|
|
|
- row["read_receipts"] = cursorData.int(forColumnIndex: 11)
|
|
|
+ row["read_receipts"] = cursorData.string(forColumnIndex: 11)
|
|
|
row["chat_id"] = cursorData.string(forColumnIndex: 12)
|
|
|
row["file_id"] = cursorData.string(forColumnIndex: 13)
|
|
|
row["attachment_flag"] = cursorData.string(forColumnIndex: 14)
|
|
@@ -381,12 +381,6 @@ public class EditorGroup: UIViewController {
|
|
|
row["is_stared"] = cursorData.string(forColumnIndex: 17)
|
|
|
row["blog_id"] = cursorData.string(forColumnIndex: 18)
|
|
|
row["isSelected"] = false
|
|
|
- if let cursorStatus = Database.shared.getRecords(fmdb: fmdb, query: "SELECT status FROM MESSAGE_STATUS WHERE message_id='\(row["message_id"] as! String)'") {
|
|
|
- while cursorStatus.next() {
|
|
|
- row["status"] = cursorStatus.string(forColumnIndex: 0)
|
|
|
- }
|
|
|
- cursorStatus.close()
|
|
|
- }
|
|
|
let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
|
|
|
let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
|
|
|
let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
|
|
@@ -418,6 +412,21 @@ public class EditorGroup: UIViewController {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ private func getRealStatus(messageId: String) -> String {
|
|
|
+ var status = "1"
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ if let cursorStatus = Database.shared.getRecords(fmdb: fmdb, query: "SELECT status, f_pin FROM MESSAGE_STATUS WHERE message_id='\(messageId)'") {
|
|
|
+ var listStatus: [Int] = []
|
|
|
+ while cursorStatus.next() {
|
|
|
+ listStatus.append(Int(cursorStatus.string(forColumnIndex: 0)!)!)
|
|
|
+ }
|
|
|
+ cursorStatus.close()
|
|
|
+ status = "\(listStatus.min() ?? 2)"
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return status
|
|
|
+ }
|
|
|
+
|
|
|
private func chatDate(stringDate: String, messageId: String) -> String {
|
|
|
let date = Date(milliseconds: Int64(stringDate)!)
|
|
|
let calendar = Calendar.current
|
|
@@ -692,6 +701,9 @@ public class EditorGroup: UIViewController {
|
|
|
if row != nil && section != nil {
|
|
|
self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
}
|
|
|
+ if self.reffId != nil && self.reffId == chatData[CoreMessage_TMessageKey.MESSAGE_ID]! {
|
|
|
+ self.deleteReplyView()
|
|
|
+ }
|
|
|
} else {
|
|
|
self.dataMessages[idx!]["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
@@ -700,9 +712,6 @@ public class EditorGroup: UIViewController {
|
|
|
self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
}
|
|
|
}
|
|
|
- if self.reffId != nil && self.reffId == chatData[CoreMessage_TMessageKey.MESSAGE_ID]! {
|
|
|
- self.deleteReplyView()
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
else if (chatData.keys.contains("message_id")) {
|
|
@@ -716,6 +725,9 @@ public class EditorGroup: UIViewController {
|
|
|
if row != nil && section != nil {
|
|
|
self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
}
|
|
|
+ if self.reffId != nil && self.reffId == chatData["message_id"]! {
|
|
|
+ self.deleteReplyView()
|
|
|
+ }
|
|
|
} else {
|
|
|
self.dataMessages[idx!]["status"] = chatData[CoreMessage_TMessageKey.STATUS]!
|
|
|
let section = self.dataDates.firstIndex(of: self.dataMessages[idx!]["chat_date"] as! String)
|
|
@@ -724,9 +736,6 @@ public class EditorGroup: UIViewController {
|
|
|
self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
}
|
|
|
}
|
|
|
- if self.reffId != nil && self.reffId == chatData["message_id"]! {
|
|
|
- self.deleteReplyView()
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
@@ -739,9 +748,6 @@ public class EditorGroup: UIViewController {
|
|
|
if row != nil && section != nil {
|
|
|
self.tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
|
|
|
}
|
|
|
- if self.reffId != nil && self.reffId! == messageId {
|
|
|
- self.deleteReplyView()
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1104,6 +1110,10 @@ public class EditorGroup: UIViewController {
|
|
|
if (self.dataTopic["chat_id"] as! String != "") {
|
|
|
opposite_pin = self.dataTopic["chat_id"] as! String
|
|
|
}
|
|
|
+ var read_receipts = read_receipts
|
|
|
+ if isAck {
|
|
|
+ read_receipts = "8"
|
|
|
+ }
|
|
|
let message = CoreMessage_TMessageBank.sendMessage(l_pin: dataGroup["group_id"] as! String, message_scope_id: message_scope_id, status: status, message_text: message_text, credential: credential, attachment_flag: attachment_flag, ex_blog_id: ex_blog_id, message_large_text: message_large_text, ex_format: ex_format, image_id: image_id, audio_id: audio_id, video_id: video_id, file_id: file_id, thumb_id: thumb_id, reff_id: reff_id, read_receipts: read_receipts, chat_id: dataTopic["chat_id"] as! String, is_call_center: is_call_center, call_center_id: call_center_id, opposite_pin: opposite_pin)
|
|
|
Nexilis.addQueueMessage(message: message)
|
|
|
let messageId = String(message.mBodies[CoreMessage_TMessageKey.MESSAGE_ID]!)
|
|
@@ -1119,7 +1129,7 @@ public class EditorGroup: UIViewController {
|
|
|
row["video_id"] = video_id
|
|
|
row["image_id"] = image_id
|
|
|
row["thumb_id"] = thumb_id
|
|
|
- row["read_receipts"] = 0
|
|
|
+ row["read_receipts"] = read_receipts
|
|
|
row["chat_id"] = dataTopic["chat_id"]!!
|
|
|
row["file_id"] = file_id
|
|
|
row["attachment_flag"] = attachment_flag
|
|
@@ -2522,10 +2532,13 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
|
|
|
statusMessage.trailingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: -8).isActive = true
|
|
|
statusMessage.widthAnchor.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" ) {
|
|
|
+ let status = getRealStatus(messageId: dataMessages[indexPath.row]["message_id"] as! String)
|
|
|
+ if (status == "1" || status == "2" ) {
|
|
|
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 (status == "3") {
|
|
|
statusMessage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.lightGray)
|
|
|
+ } else if (status == "8") {
|
|
|
+ statusMessage.image = UIImage(named: "message_status_ack", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal)
|
|
|
} else {
|
|
|
statusMessage.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.systemBlue)
|
|
|
}
|
|
@@ -2667,18 +2680,22 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
|
|
|
if dataMessages[indexPath.row]["read_receipts"] as? String == "8" {
|
|
|
let imageAckView = UIImageView()
|
|
|
var imageAck = UIImage(named: "ack_icon_gray", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal)
|
|
|
- if dataMessages[indexPath.row]["status"] as? String == "8" {
|
|
|
- imageAck = UIImage(named: "ack_icon", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal)
|
|
|
- }
|
|
|
- imageAckView.image = imageAck
|
|
|
cellMessage.contentView.addSubview(imageAckView)
|
|
|
imageAckView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
imageAckView.widthAnchor.constraint(equalToConstant: 30).isActive = true
|
|
|
imageAckView.heightAnchor.constraint(equalToConstant: 30).isActive = true
|
|
|
if (dataMessages[indexPath.row]["f_pin"] as? String == idMe) {
|
|
|
+ let status = getRealStatus(messageId: dataMessages[indexPath.row]["message_id"] as! String)
|
|
|
+ if status == "8" {
|
|
|
+ imageAck = UIImage(named: "ack_icon", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal)
|
|
|
+ }
|
|
|
imageAckView.topAnchor.constraint(equalTo: containerMessage.bottomAnchor, constant: 5).isActive = true
|
|
|
imageAckView.trailingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 30).isActive = true
|
|
|
} else {
|
|
|
+ let status = dataMessages[indexPath.row]["status"] as? String
|
|
|
+ if status == "8" {
|
|
|
+ imageAck = UIImage(named: "ack_icon", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal)
|
|
|
+ }
|
|
|
imageAckView.topAnchor.constraint(equalTo: containerMessage.bottomAnchor, constant: 5).isActive = true
|
|
|
imageAckView.leadingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -30).isActive = true
|
|
|
let tap = ObjectGesture(target: self, action: #selector(tapAck(_:)))
|
|
@@ -2686,6 +2703,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
|
|
|
imageAckView.addGestureRecognizer(tap)
|
|
|
imageAckView.isUserInteractionEnabled = true
|
|
|
}
|
|
|
+ imageAckView.image = imageAck
|
|
|
}
|
|
|
|
|
|
messageText.numberOfLines = 0
|