Bladeren bron

copy conversation list chat gpt to DigiXLite

alqindiirsyam 1 jaar geleden
bovenliggende
commit
5964b440f0

+ 20 - 3
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Control/ContactChatViewController.swift

@@ -360,6 +360,13 @@ class ContactChatViewController: UITableViewController {
     
     private func getContacts(completion: @escaping ()->()) {
         self.contacts.removeAll()
+        let gptUser = User(pin: "-997",
+                        firstName: "GPT SmartBot",
+                        lastName: "",
+                        thumb: "",
+                        userType: "0",
+                        official: "1")
+        contacts.append(gptUser)
         DispatchQueue.global().async {
             Database.shared.database?.inTransaction({ (fmdb, rollback) in
                 if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT f_pin, first_name, last_name, image_id, official_account, user_type FROM BUDDY where f_pin <> '\(UserDefaults.standard.string(forKey: "me")!)' order by 5 desc, 2 collate nocase asc") {
@@ -540,6 +547,12 @@ extension ContactChatViewController {
             } else {
                 data = contacts[indexPath.row]
             }
+            if data.pin == "-997" {
+                let smartChatVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "chatGptVC") as! ChatGPTBotView
+                smartChatVC.hidesBottomBarWhenPushed = true
+                navigationController?.show(smartChatVC, sender: nil)
+                return
+            }
             if let chooser = isChooser {
                 var exblock = User.getDataCanNil(pin: data.pin)?.ex_block
                 exblock = exblock == nil ? "0" : exblock!.isEmpty ? "0" : exblock!
@@ -867,9 +880,13 @@ extension ContactChatViewController {
                     data = contacts[indexPath.row]
                 }
                 content.imageProperties.maximumSize = CGSize(width: 40, height: 40)
-                getImage(name: data.thumb, placeholderImage: UIImage(named: "Profile---Purple", in: Bundle.resourceBundle(for: DigiX.self), with: nil), isCircle: true, tableView: tableView, indexPath: indexPath, completion: { result, isDownloaded, image in
-                    content.image = image
-                })
+                if data.pin == "-997" {
+                    content.image = UIImage(named: "pb_gpt_bot", in: Bundle.resourceBundle(for: DigiX.self), with: nil)
+                } else {
+                    getImage(name: data.thumb, placeholderImage: UIImage(named: "Profile---Purple", in: Bundle.resourceBundle(for: DigiX.self), with: nil), isCircle: true, tableView: tableView, indexPath: indexPath, completion: { result, isDownloaded, image in
+                        content.image = image
+                    })
+                }
                 if User.isOfficial(official_account: data.official ?? "") || User.isOfficialRegular(official_account: data.official ?? "") {
                     content.attributedText = self.set(image: UIImage(named: "ic_official_flag", in: Bundle.resourceBundle(for: DigiX.self), with: nil)!, with: "  \(data.fullName)", size: 15, y: -4, colorText: UIColor.officialColor)
                     

+ 3 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController.swift

@@ -547,7 +547,9 @@ extension ContactChatViewController {
                 data = contacts[indexPath.row]
             }
             if data.pin == "-997" {
-                APIS.openSmartChatbot()
+                let smartChatVC = AppStoryBoard.Palio.instance.instantiateViewController(identifier: "chatGptVC") as! ChatGPTBotView
+                smartChatVC.hidesBottomBarWhenPushed = true
+                navigationController?.show(smartChatVC, sender: nil)
                 return
             }
             if let chooser = isChooser {