Kaynağa Gözat

update status image in view grouping images

alqindiirsyam 2 yıl önce
ebeveyn
işleme
0c859d09b4

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


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

@@ -2719,7 +2719,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                     message.mStatus = CoreMessage_TMessageUtil.getTID()
                     message.mBodies[CoreMessage_TMessageKey.L_PIN] = f_pin
                     message.mBodies[CoreMessage_TMessageKey.MESSAGE_ID] = "-2,\(valueListGroupImages[i].messageId)"
-                    _ = Nexilis.write(message: message)
+                    _ = DigiX.write(message: message)
                 }
             } else {
                 Database.shared.database?.inTransaction({ (fmdb, rollback) in

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

@@ -32,6 +32,23 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
         tableViewImages.anchor(top: self.view.safeAreaLayoutGuide.topAnchor, left: self.view.safeAreaLayoutGuide.leftAnchor, bottom: self.view.safeAreaLayoutGuide.bottomAnchor, right: self.view.safeAreaLayoutGuide.rightAnchor)
         
         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)
+    }
+    
+    @objc func onStatusChat(notification: NSNotification) {
+        DispatchQueue.main.async { [self] in
+            let data:[AnyHashable : Any] = notification.userInfo!
+            if let dataMessage = data["message"] as? TMessage {
+                var messageId = dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)
+                messageId = messageId.contains("-2") ? String(messageId.split(separator: ",")[1]) : messageId
+                if let idx = listGroupingImages.firstIndex(where: { $0.messageId == messageId }) {
+                    listGroupingImages[idx].status = dataMessage.getBody(key: CoreMessage_TMessageKey.STATUS)
+                    tableViewImages.reloadRows(at: [IndexPath(row: idx, section: 0)], with: .none)
+                }
+            }
+        }
     }
     
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

+ 17 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/ListGroupImages.swift

@@ -32,6 +32,23 @@ class ListGroupImages: UIViewController, UITableViewDataSource, UITableViewDeleg
         tableViewImages.anchor(top: self.view.safeAreaLayoutGuide.topAnchor, left: self.view.safeAreaLayoutGuide.leftAnchor, bottom: self.view.safeAreaLayoutGuide.bottomAnchor, right: self.view.safeAreaLayoutGuide.rightAnchor)
         
         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)
+    }
+    
+    @objc func onStatusChat(notification: NSNotification) {
+        DispatchQueue.main.async { [self] in
+            let data:[AnyHashable : Any] = notification.userInfo!
+            if let dataMessage = data["message"] as? TMessage {
+                var messageId = dataMessage.getBody(key: CoreMessage_TMessageKey.MESSAGE_ID)
+                messageId = messageId.contains("-2") ? String(messageId.split(separator: ",")[1]) : messageId
+                if let idx = listGroupingImages.firstIndex(where: { $0.messageId == messageId }) {
+                    listGroupingImages[idx].status = dataMessage.getBody(key: CoreMessage_TMessageKey.STATUS)
+                    tableViewImages.reloadRows(at: [IndexPath(row: idx, section: 0)], with: .none)
+                }
+            }
+        }
     }
     
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {