瀏覽代碼

last state editor

alqindiirsyam 2 年之前
父節點
當前提交
87773ee2f6

+ 24 - 0
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Chat/EditorGroup.swift

@@ -95,6 +95,7 @@ public class EditorGroup: UIViewController {
     let maxFakeProgMultip = 2
     var groupImages: [String:[ImageGrouping]] = [:]
     var titleText: String!
+    var lastY: CGFloat = 0
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -103,6 +104,11 @@ public class EditorGroup: UIViewController {
             super.viewDidDisappear(true)
             self.removeFromParent()
             self.dismiss(animated: true, completion: nil)
+            var l_pin = self.dataGroup["group_id"] as! String
+            if (self.dataTopic["chat_id"] as! String != "") {
+                l_pin = self.dataTopic["chat_id"] as! String
+            }
+            UserDefaults.standard.set("\(textFieldSend.textColor != UIColor.lightGray ? textFieldSend.text! : ""),\(reffId ?? "")", forKey: "saved_\(l_pin)")
         }
     }
     
@@ -237,6 +243,7 @@ public class EditorGroup: UIViewController {
                         }
                         _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE", _where: "(l_pin='\(self.dataGroup["group_id"]!!)' and chat_id='\(self.dataTopic["chat_id"]!!)') and message_scope_id='4'")
                         _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE_SUMMARY", _where: "l_pin='\(l_pin)'")
+                        UserDefaults.standard.removeObject(forKey: "saved_\(l_pin)")
                         if self.fromNotification {
                             self.didTapExit()
                         } else {
@@ -372,6 +379,22 @@ public class EditorGroup: UIViewController {
                 }
             }
         } else {
+            var l_pin = self.dataGroup["group_id"] as! String
+            if (self.dataTopic["chat_id"] as! String != "") {
+                l_pin = self.dataTopic["chat_id"] as! String
+            }
+            if let dataSaved = UserDefaults.standard.string(forKey: "saved_\(l_pin)") {
+                let last_m = dataSaved.components(separatedBy: ",")[0]
+                let last_r = dataSaved.components(separatedBy: ",")[1]
+                if !last_m.isEmpty {
+                    textFieldSend.text = last_m
+                    textFieldSend.textColor = UIColor.black
+                }
+                
+                if !last_r.isEmpty {
+                    reffId = last_r
+                }
+            }
             tableChatView.scrollToBottom(isAnimated: false)
         }
         tableChatView.keyboardDismissMode = .interactive
@@ -2922,6 +2945,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
     }
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        lastY = scrollView.contentOffset.y
         checkNewMessage(tableView: self.tableChatView)
     }
     

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

@@ -108,6 +108,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     let maxFakeProgMultip = 2
     var groupImages: [String:[ImageGrouping]] = [:]
     var titleText: String!
+    var lastY: CGFloat = 0
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -120,6 +121,10 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
             super.viewDidDisappear(true)
             self.removeFromParent()
             self.dismiss(animated: true, completion: nil)
+            if !isContactCenter {
+                let l_pin = self.dataPerson["f_pin"]!!
+                UserDefaults.standard.set("\(textFieldSend.textColor != UIColor.lightGray ? textFieldSend.text! : ""),\(reffId ?? "")", forKey: "saved_\(l_pin)")
+            }
         }
     }
     
@@ -310,6 +315,8 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         Database.shared.database?.inTransaction({ (fmdb, rollback) in
                             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE", _where: "(f_pin='\(self.dataPerson["f_pin"]!!)' or l_pin='\(self.dataPerson["f_pin"]!!)') and (message_scope_id='3' or message_scope_id='18') and is_call_center = 0")
                             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE_SUMMARY", _where: "l_pin='\(self.dataPerson["f_pin"]!!)'")
+                            let l_pin = self.dataPerson["f_pin"]!!
+                            UserDefaults.standard.removeObject(forKey: "saved_\(l_pin)")
                             if self.fromNotification {
                                 self.didTapExit()
                             } else {
@@ -617,6 +624,19 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                     }
                 }
             } else {
+                let l_pin = self.dataPerson["f_pin"]
+                if let dataSaved = UserDefaults.standard.string(forKey: "saved_\(l_pin)") {
+                    let last_m = dataSaved.components(separatedBy: ",")[0]
+                    let last_r = dataSaved.components(separatedBy: ",")[1]
+                    if !last_m.isEmpty {
+                        textFieldSend.text = last_m
+                        textFieldSend.textColor = UIColor.black
+                    }
+                    
+                    if !last_r.isEmpty {
+                        reffId = last_r
+                    }
+                }
                 tableChatView.scrollToBottom(isAnimated: false)
             }
         } else if isContactCenter && onGoingCC {
@@ -4176,6 +4196,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
     }
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        lastY = scrollView.contentOffset.y
         checkNewMessage(tableView: self.tableChatView)
     }
     
@@ -6560,4 +6581,3 @@ public class ImageGrouping {
         self.dataTopic = dataTopic
     }
 }
-

+ 24 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -95,6 +95,7 @@ public class EditorGroup: UIViewController {
     let maxFakeProgMultip = 2
     var groupImages: [String:[ImageGrouping]] = [:]
     var titleText: String!
+    var lastY: CGFloat = 0
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -103,6 +104,11 @@ public class EditorGroup: UIViewController {
             super.viewDidDisappear(true)
             self.removeFromParent()
             self.dismiss(animated: true, completion: nil)
+            var l_pin = self.dataGroup["group_id"] as! String
+            if (self.dataTopic["chat_id"] as! String != "") {
+                l_pin = self.dataTopic["chat_id"] as! String
+            }
+            UserDefaults.standard.set("\(textFieldSend.textColor != UIColor.lightGray ? textFieldSend.text! : ""),\(reffId ?? "")", forKey: "saved_\(l_pin)")
         }
     }
     
@@ -237,6 +243,7 @@ public class EditorGroup: UIViewController {
                         }
                         _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE", _where: "(l_pin='\(self.dataGroup["group_id"]!!)' and chat_id='\(self.dataTopic["chat_id"]!!)') and message_scope_id='4'")
                         _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE_SUMMARY", _where: "l_pin='\(l_pin)'")
+                        UserDefaults.standard.removeObject(forKey: "saved_\(l_pin)")
                         if self.fromNotification {
                             self.didTapExit()
                         } else {
@@ -372,6 +379,22 @@ public class EditorGroup: UIViewController {
                 }
             }
         } else {
+            var l_pin = self.dataGroup["group_id"] as! String
+            if (self.dataTopic["chat_id"] as! String != "") {
+                l_pin = self.dataTopic["chat_id"] as! String
+            }
+            if let dataSaved = UserDefaults.standard.string(forKey: "saved_\(l_pin)") {
+                let last_m = dataSaved.components(separatedBy: ",")[0]
+                let last_r = dataSaved.components(separatedBy: ",")[1]
+                if !last_m.isEmpty {
+                    textFieldSend.text = last_m
+                    textFieldSend.textColor = UIColor.black
+                }
+                
+                if !last_r.isEmpty {
+                    reffId = last_r
+                }
+            }
             tableChatView.scrollToBottom(isAnimated: false)
         }
         tableChatView.keyboardDismissMode = .interactive
@@ -2922,6 +2945,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
     }
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        lastY = scrollView.contentOffset.y
         checkNewMessage(tableView: self.tableChatView)
     }
     

+ 21 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -108,6 +108,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
     let maxFakeProgMultip = 2
     var groupImages: [String:[ImageGrouping]] = [:]
     var titleText: String!
+    var lastY: CGFloat = 0
     
     public override func viewDidDisappear(_ animated: Bool) {
         if self.isMovingFromParent {
@@ -120,6 +121,10 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
             super.viewDidDisappear(true)
             self.removeFromParent()
             self.dismiss(animated: true, completion: nil)
+            if !isContactCenter {
+                let l_pin = self.dataPerson["f_pin"]!!
+                UserDefaults.standard.set("\(textFieldSend.textColor != UIColor.lightGray ? textFieldSend.text! : ""),\(reffId ?? "")", forKey: "saved_\(l_pin)")
+            }
         }
     }
     
@@ -310,6 +315,8 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                         Database.shared.database?.inTransaction({ (fmdb, rollback) in
                             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE", _where: "(f_pin='\(self.dataPerson["f_pin"]!!)' or l_pin='\(self.dataPerson["f_pin"]!!)') and (message_scope_id='3' or message_scope_id='18') and is_call_center = 0")
                             _ = Database.shared.deleteRecord(fmdb: fmdb, table: "MESSAGE_SUMMARY", _where: "l_pin='\(self.dataPerson["f_pin"]!!)'")
+                            let l_pin = self.dataPerson["f_pin"]!!
+                            UserDefaults.standard.removeObject(forKey: "saved_\(l_pin)")
                             if self.fromNotification {
                                 self.didTapExit()
                             } else {
@@ -617,6 +624,19 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
                     }
                 }
             } else {
+                let l_pin = self.dataPerson["f_pin"]
+                if let dataSaved = UserDefaults.standard.string(forKey: "saved_\(l_pin)") {
+                    let last_m = dataSaved.components(separatedBy: ",")[0]
+                    let last_r = dataSaved.components(separatedBy: ",")[1]
+                    if !last_m.isEmpty {
+                        textFieldSend.text = last_m
+                        textFieldSend.textColor = UIColor.black
+                    }
+                    
+                    if !last_r.isEmpty {
+                        reffId = last_r
+                    }
+                }
                 tableChatView.scrollToBottom(isAnimated: false)
             }
         } else if isContactCenter && onGoingCC {
@@ -4176,6 +4196,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
     }
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        lastY = scrollView.contentOffset.y
         checkNewMessage(tableView: self.tableChatView)
     }