ソースを参照

update auto download
fake upload progress

kevin 2 年 前
コミット
a804b8323b

+ 33 - 31
appbuilder-ios/NexilisLite/NexilisLite/Source/Download.swift

@@ -49,43 +49,45 @@ public class Download {
         _ = startHTTP(filename: forKey, baseURL: DOWNLOAD_URL, completion: completion)
     }
     
-    public func startHTTP(filename: String, baseURL: String, completion: @escaping (String, Double)->()) -> DownloadRequest {
-        var sep = ""
-        if baseURL.last != "/" {
-            sep = "/"
-        }
-        let fullURL = "\(baseURL)\(sep)\(filename)"
-        do {
-//            let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory, in: .userDomainMask, options: [.removePreviousFile, .createIntermediateDirectories])
-            let downloadRequest = AF.download(fullURL)
-            .downloadProgress(queue: downloadBufferQueue) { progress in
-                let frac = progress.fractionCompleted*100
-                if frac != 100.0 {
-                    completion(filename,frac)
-                }
+    public func startHTTP(filename: String, baseURL: String, completion: @escaping (String, Double)->()) {
+        let download = Nexilis.getDownload(forKey: filename)
+        if download == nil {
+            Nexilis.addDownload(forKey: filename, download: self)
+            var sep = ""
+            if baseURL.last != "/" {
+                sep = "/"
             }
-            .responseData { result in
-                if let successResponse = result.value {
-                    //print("Response success")
-                    do {
-                        let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
-                        let url = documentDir.appendingPathComponent(filename)
-                        //print("write file \(url.path)")
-                        try successResponse.write(to: url)
-                        completion(filename,100)
+            let fullURL = "\(baseURL)\(sep)\(filename)"
+            do {
+                let downloadRequest = AF.download(fullURL)
+                .downloadProgress(queue: downloadBufferQueue) { progress in
+                    let frac = progress.fractionCompleted*100
+                    if frac != 100.0 {
+                        completion(filename,frac)
                     }
-                    catch {}
                 }
-                else {
-                    let statusCode = result.response?.statusCode
-                    //print("Response fail: \(statusCode)")
-                    completion(filename,0)
+                .responseData { result in
+                    if let successResponse = result.value {
+                        //print("Response success")
+                        do {
+                            let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+                            let url = documentDir.appendingPathComponent(filename)
+                            //print("write file \(url.path)")
+                            try successResponse.write(to: url)
+                            Nexilis.removeDownload(forKey: filename)
+                            completion(filename,100)
+                        }
+                        catch {}
+                    }
+                    else {
+                        let statusCode = result.response?.statusCode
+                        //print("Response fail: \(statusCode)")
+                        completion(filename,0)
+                    }
                 }
             }
-            return downloadRequest
+            catch {}
         }
-        catch {}
-        
         
     }
     

+ 8 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -1267,6 +1267,14 @@ public class Nexilis: NSObject {
         return _result
     }
     
+    static func removeDownload(forKey: String) -> Download? {
+        var _result: Download? = nil
+        downloadQueue.sync {
+            _result = self.DOWNLOAD_DICT.removeValue(forKey: forKey)
+        }
+        return _result
+    }
+    
     static func writeImageToFile(data: Data, fileName: String){
         guard let directory = FileManager.default.urls(for: .picturesDirectory, in: .userDomainMask).last else {
             return

+ 87 - 31
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -86,10 +86,13 @@ public class EditorGroup: UIViewController {
     var timerCheckLink: Timer?
     var lastPositionCursorMention = 0
     var timerLongPressLink: Timer?
+    var timerFakeProgress: Timer?
     var lastTouchPoint: CGPoint = .zero
     var isLinkCopied = false
     var touchedSubview = UIView()
     var listViewOnSection: [UIView] = []
+    var fakeProgMultip = 0
+    let maxFakeProgMultip = 2
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -598,12 +601,11 @@ public class EditorGroup: UIViewController {
         viewAppBar.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(seeProfileTapped)))
     }
     
-    @objc func onUploadChat(notification: NSNotification) {
-        let data:[AnyHashable : Any] = notification.userInfo!
+    func updateProgress(_ data: [AnyHashable: Any]){
         var isImage = false
-        var idx = dataMessages.lastIndex(where: { $0["video_id"] as! String == data["name"] as! String })
+        var idx = dataMessages.lastIndex(where: { $0["video_id"] as! String == data["name"] as! String || $0["video_id"] as? String == data["video_id"] as? String })
         if (idx == nil) {
-            idx = dataMessages.lastIndex(where: { $0["image_id"] as! String == data["name"] as! String })
+            idx = dataMessages.lastIndex(where: { $0["image_id"] as! String == data["name"] as! String || $0["image_id"] as? String == data["image_id"] as? String })
             isImage = true
         }
         if (idx != nil) {
@@ -617,6 +619,14 @@ public class EditorGroup: UIViewController {
             }
             DispatchQueue.main.async {
                 let indexPath = IndexPath(row: row!, section: section!)
+                if(self.fakeProgMultip < self.maxFakeProgMultip){
+                    self.fakeProgMultip = self.fakeProgMultip + 1
+                }
+                let fakeProgress = Double(self.fakeProgMultip) * (100.0 / Double(self.maxFakeProgMultip))
+                let progress = max(data["progress"] as! Double, fakeProgress)
+                if(data["progress"] as! Double == 100.0){
+                    self.fakeProgMultip = 0
+                }
                 if let cell = self.tableChatView.cellForRow(at: indexPath) {
                     for view in cell.contentView.subviews {
                         if !(view is UILabel) && !(view is UIImageView) {
@@ -625,17 +635,18 @@ public class EditorGroup: UIViewController {
                                     if viewInContainer.subviews.count == 0 {
                                         return
                                     }
-                                    var containerView = UIView()
+                                    var containerView : UIView?
                                     if (isImage) {
                                         containerView = viewInContainer.subviews[0]
-                                    } else {
+                                    } else if viewInContainer.subviews.count > 1 {
                                         containerView = viewInContainer.subviews[1]
                                     }
-                                    let loading = containerView.layer.sublayers![1] as! CAShapeLayer
-                                    loading.strokeEnd = CGFloat(data["progress"] as! Double / 100)
-                                    if (data["progress"] as! Double == 100.0) {
-                                        self.dataMessages[idx!]["progress"] = data["progress"]
-                                        self.tableChatView.reloadRows(at: [indexPath], with: .none)
+                                    if let loading = containerView?.layer.sublayers?[1] as? CAShapeLayer {
+                                        loading.strokeEnd = CGFloat(progress / 100)
+                                        if (progress == 100.0) {
+                                            self.dataMessages[idx!]["progress"] = progress
+                                            self.tableChatView.reloadRows(at: [indexPath], with: .none)
+                                        }
                                     }
                                 }
                             }
@@ -644,11 +655,19 @@ public class EditorGroup: UIViewController {
                 }
             }
         } else {
-            idx = dataMessages.lastIndex(where: { $0["file_id"] as! String == data["name"] as! String })
+            idx = dataMessages.lastIndex(where: { $0["file_id"] as! String == data["name"] as! String || $0["file_id"] as? String == data["file_id"] as? String })
             if (idx != nil) {
                 DispatchQueue.main.async {
                     let section = 0
                     let indexPath = IndexPath(row: idx!, section: section)
+                    if(self.fakeProgMultip < self.maxFakeProgMultip){
+                        self.fakeProgMultip = self.fakeProgMultip + 1
+                    }
+                    let fakeProgress = Double(self.fakeProgMultip) * (100.0 / Double(self.maxFakeProgMultip))
+                    let progress = max(data["progress"] as! Double, fakeProgress)
+                    if(data["progress"] as! Double == 100.0){
+                        self.fakeProgMultip = 0
+                    }
                     if let cell = self.tableChatView.cellForRow(at: indexPath) {
                         for view in cell.contentView.subviews {
                             if !(view is UILabel) && !(view is UIImageView) {
@@ -660,9 +679,9 @@ public class EditorGroup: UIViewController {
                                                     return
                                                 }
                                                 let loading = viewInContainer.layer.sublayers![1] as! CAShapeLayer
-                                                loading.strokeEnd = CGFloat(data["progress"] as! Double / 100)
-                                                if (data["progress"] as! Double == 100.0) {
-                                                    self.dataMessages[idx!]["progress"] = data["progress"]
+                                                loading.strokeEnd = CGFloat(progress / 100)
+                                                if (progress == 100.0) {
+                                                    self.dataMessages[idx!]["progress"] = progress
                                                     self.tableChatView.reloadRows(at: [indexPath], with: .none)
                                                 }
                                             }
@@ -677,6 +696,11 @@ public class EditorGroup: UIViewController {
         }
     }
     
+    @objc func onUploadChat(notification: NSNotification) {
+        let data:[AnyHashable : Any] = notification.userInfo!
+        updateProgress(data)
+    }
+    
     @objc func onReceiveMessage(notification: NSNotification) {
         DispatchQueue.main.async {
             let data:[AnyHashable : Any] = notification.userInfo!
@@ -1326,6 +1350,15 @@ public class EditorGroup: UIViewController {
                 self.tableChatView.endUpdates()
             }
         }
+        //        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
+        //            self.timerFakeProgress = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
+        //                self.updateProgress(row as [AnyHashable : Any])
+        //                if self.fakeProgMultip == self.maxFakeProgMultip {
+        //                    self.timerFakeProgress?.invalidate()
+        //                    self.fakeProgMultip = 0
+        //                }
+        //            }
+        //        }
     }
     
     private func getCounter() {
@@ -1485,30 +1518,53 @@ public class EditorGroup: UIViewController {
                             }
                         }
                         DispatchQueue.main.async { [self] in
-                            let section = self.dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
-                            let row = self.dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
+                            let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
+                            let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
                             if row != nil && section != nil{
                                 tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .automatic)
                             }
                         }
                     }
-                }  else if dataMessages[index]["video_id"] as? String != nil && !((dataMessages[index]["video_id"] as? String)!.isEmpty){
-                    let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
-                    let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
-                    if row != nil && section != nil{
-                        let indexPath = IndexPath(row: row!, section: section!)
-                        if let cell = tableChatView.cellForRow(at: indexPath) {
-                            for view in cell.contentView.subviews {
-                                if view is UIImageView {
-                                    let objectTap = ObjectGesture()
-                                    objectTap.video_id = dataMessages[index]["video_id"] as! String
-                                    objectTap.imageView = view as! UIImageView
-                                    objectTap.indexPath = indexPath
-                                    contentMessageTapped(objectTap)
-                                    break
+                } else if dataMessages[index]["video_id"] as? String != nil && !((dataMessages[index]["video_id"] as? String)!.isEmpty){
+                    Download().startHTTP(forKey: dataMessages[index]["video_id"] as! String) { (name, progress) in
+                        guard progress == 100 else {
+                            return
+                        }
+                        let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
+                        let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
+                        let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
+                        if let dirPath = paths.first {
+                            let videoURL = URL(fileURLWithPath: dirPath).appendingPathComponent(self.dataMessages[index]["video_id"] as! String)
+                            let save = UserDefaults.standard.bool(forKey: "saveToGallery")
+                            if save {
+                                PHPhotoLibrary.shared().performChanges({
+                                    PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoURL)
+                                }) { saved, error in
+                                    
                                 }
                             }
                         }
+                        DispatchQueue.main.async { [self] in
+                            let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
+                            let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
+                            if row != nil && section != nil{
+                                tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .automatic)
+                            }
+                        }
+                    }
+                }
+                else if dataMessages[index]["file_id"] as? String != nil && !((dataMessages[index]["file_id"] as? String)!.isEmpty) {
+                    Download().startHTTP(forKey: dataMessages[index]["file_id"] as! String) { (name, progress) in
+                        guard progress == 100 else {
+                            return
+                        }
+                        DispatchQueue.main.async { [self] in
+                            let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
+                            let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
+                            if row != nil && section != nil{
+                                tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .automatic)
+                            }
+                        }
                     }
                 }
             }

+ 84 - 28
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -96,6 +96,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     var isAlwaysHideLinkPreview = false
     var timerCheckLink: Timer?
     var timerLongPressLink: Timer?
+    var timerFakeProgress: Timer?
     var lastTouchPoint: CGPoint = .zero
     var isLinkCopied = false
     var touchedSubview = UIView()
@@ -103,6 +104,8 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     var fromVCAC = false
     var serviceIdCC = ""
     var isDirectCC = false
+    var fakeProgMultip = 0
+    let maxFakeProgMultip = 2
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -1165,12 +1168,11 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
         }
     }
     
-    @objc func onUploadChat(notification: NSNotification) {
-        let data:[AnyHashable : Any] = notification.userInfo!
+    func updateProgress(_ data: [AnyHashable : Any]){
         var isImage = false
-        var idx = dataMessages.lastIndex(where: { $0["video_id"] as? String == data["name"] as? String })
+        var idx = dataMessages.lastIndex(where: { $0["video_id"] as? String == data["name"] as? String || $0["video_id"] as? String == data["video_id"] as? String })
         if (idx == nil) {
-            idx = dataMessages.lastIndex(where: { $0["image_id"] as? String == data["name"] as? String })
+            idx = dataMessages.lastIndex(where: { $0["image_id"] as? String == data["name"] as? String || $0["image_id"] as? String == data["image_id"] as? String })
             isImage = true
         }
         if (idx != nil) {
@@ -1184,6 +1186,14 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
             }
             DispatchQueue.main.async {
                 let indexPath = IndexPath(row: row!, section: section!)
+                if(self.fakeProgMultip < self.maxFakeProgMultip){
+                    self.fakeProgMultip = self.fakeProgMultip + 1
+                }
+                let fakeProgress = Double(self.fakeProgMultip) * (100.0 / Double(self.maxFakeProgMultip))
+                let progress = max(data["progress"] as! Double, fakeProgress)
+                if(data["progress"] as! Double == 100.0){
+                    self.fakeProgMultip = 0
+                }
                 if let cell = self.tableChatView.cellForRow(at: indexPath) {
                     for view in cell.contentView.subviews {
                         if !(view is UILabel) && !(view is UIImageView) {
@@ -1192,17 +1202,18 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                                     if viewInContainer.subviews.count == 0 {
                                         return
                                     }
-                                    var containerView = UIView()
+                                    var containerView : UIView?
                                     if (isImage) {
                                         containerView = viewInContainer.subviews[0]
-                                    } else {
+                                    } else if viewInContainer.subviews.count > 1 {
                                         containerView = viewInContainer.subviews[1]
                                     }
-                                    let loading = containerView.layer.sublayers![1] as! CAShapeLayer
-                                    loading.strokeEnd = CGFloat(data["progress"] as! Double / 100)
-                                    if (data["progress"] as! Double == 100.0) {
-                                        self.dataMessages[idx!]["progress"] = data["progress"]
-                                        self.tableChatView.reloadRows(at: [indexPath], with: .none)
+                                    if let loading = containerView?.layer.sublayers?[1] as? CAShapeLayer {
+                                        loading.strokeEnd = CGFloat(progress / 100)
+                                        if (progress == 100.0) {
+                                            self.dataMessages[idx!]["progress"] = progress
+                                            self.tableChatView.reloadRows(at: [indexPath], with: .none)
+                                        }
                                     }
                                 }
                             }
@@ -1211,7 +1222,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 }
             }
         } else {
-            idx = dataMessages.lastIndex(where: { $0["file_id"] as? String == data["name"] as? String })
+            idx = dataMessages.lastIndex(where: { $0["file_id"] as? String == data["name"] as? String || $0["file_id"] as? String == data["file_id"] as? String })
             if (idx != nil) {
                 let section = dataDates.firstIndex(of: dataMessages[idx!]["chat_date"] as! String)
                 if section == nil {
@@ -1223,6 +1234,14 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 }
                 DispatchQueue.main.async {
                     let indexPath = IndexPath(row: row!, section: section!)
+                    if(self.fakeProgMultip < self.maxFakeProgMultip){
+                        self.fakeProgMultip = self.fakeProgMultip + 1
+                    }
+                    let fakeProgress = Double(self.fakeProgMultip) * (100.0 / Double(self.maxFakeProgMultip))
+                    let progress = max(data["progress"] as! Double, fakeProgress)
+                    if(data["progress"] as! Double == 100.0){
+                        self.fakeProgMultip = 0
+                    }
                     if let cell = self.tableChatView.cellForRow(at: indexPath) {
                         for view in cell.contentView.subviews {
                             if !(view is UILabel) && !(view is UIImageView) {
@@ -1234,9 +1253,9 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                                                     return
                                                 }
                                                 let loading = viewInContainer.layer.sublayers![1] as! CAShapeLayer
-                                                loading.strokeEnd = CGFloat(data["progress"] as! Double / 100)
-                                                if (data["progress"] as! Double == 100.0) {
-                                                    self.dataMessages[idx!]["progress"] = data["progress"]
+                                                loading.strokeEnd = CGFloat(progress / 100)
+                                                if (progress == 100.0) {
+                                                    self.dataMessages[idx!]["progress"] = progress
                                                     self.tableChatView.reloadRows(at: [indexPath], with: .none)
                                                 }
                                             }
@@ -1251,6 +1270,11 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
         }
     }
     
+    @objc func onUploadChat(notification: NSNotification) {
+        let data:[AnyHashable : Any] = notification.userInfo!
+        updateProgress(data)
+    }
+    
     
     @objc func onReceiveMessage(notification: NSNotification) {
         DispatchQueue.main.async { [self] in
@@ -2348,6 +2372,15 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                 self.tableChatView.endUpdates()
             }
         }
+//        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
+//            self.timerFakeProgress = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
+//                self.updateProgress(row as [AnyHashable : Any])
+//                if self.fakeProgMultip == self.maxFakeProgMultip {
+//                    self.timerFakeProgress?.invalidate()
+//                    self.fakeProgMultip = 0
+//                }
+//            }
+//        }
     }
     
     @objc func ccAction(sender: UIButton) {
@@ -2681,22 +2714,45 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         }
                     }
                 } else if dataMessages[index]["video_id"] as? String != nil && !((dataMessages[index]["video_id"] as? String)!.isEmpty){
-                    let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
-                    let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
-                    if row != nil && section != nil{
-                        let indexPath = IndexPath(row: row!, section: section!)
-                        if let cell = tableChatView.cellForRow(at: indexPath) {
-                            for view in cell.contentView.subviews {
-                                if view is UIImageView{
-                                    let objectTap = ObjectGesture()
-                                    objectTap.video_id = dataMessages[index]["video_id"] as! String
-                                    objectTap.imageView = view as! UIImageView
-                                    objectTap.indexPath = indexPath
-                                    contentMessageTapped(objectTap)
-                                    break
+                    Download().startHTTP(forKey: dataMessages[index]["video_id"] as! String) { (name, progress) in
+                        guard progress == 100 else {
+                            return
+                        }
+                        let nsDocumentDirectory = FileManager.SearchPathDirectory.documentDirectory
+                        let nsUserDomainMask = FileManager.SearchPathDomainMask.userDomainMask
+                        let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
+                        if let dirPath = paths.first {
+                            let videoURL = URL(fileURLWithPath: dirPath).appendingPathComponent(self.dataMessages[index]["video_id"] as! String)
+                            let save = UserDefaults.standard.bool(forKey: "saveToGallery")
+                            if save {
+                                PHPhotoLibrary.shared().performChanges({
+                                    PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoURL)
+                                }) { saved, error in
+                                    
                                 }
                             }
                         }
+                        DispatchQueue.main.async { [self] in
+                            let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
+                            let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
+                            if row != nil && section != nil{
+                                tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
+                            }
+                        }
+                    }
+                }
+                else if dataMessages[index]["file_id"] as? String != nil && !((dataMessages[index]["file_id"] as? String)!.isEmpty) {
+                    Download().startHTTP(forKey: dataMessages[index]["file_id"] as! String) { (name, progress) in
+                        guard progress == 100 else {
+                            return
+                        }
+                        DispatchQueue.main.async { [self] in
+                            let section = dataDates.firstIndex(of: dataMessages[index]["chat_date"] as! String)
+                            let row = dataMessages.filter({$0["chat_date"] as! String == dataMessages[index]["chat_date"] as! String}).firstIndex(where: { $0["message_id"] as? String == message_id})
+                            if row != nil && section != nil{
+                                tableChatView.reloadRows(at: [IndexPath(row: row!, section: section!)], with: .none)
+                            }
+                        }
                     }
                 }
             }