浏览代码

update guessed imap smtp ports and urls after successful login

cyberta 5 年之前
父节点
当前提交
2f640008af
共有 1 个文件被更改,包括 21 次插入5 次删除
  1. 21 5
      deltachat-ios/Controller/AccountSetupController.swift

+ 21 - 5
deltachat-ios/Controller/AccountSetupController.swift

@@ -328,11 +328,7 @@ class AccountSetupController: UITableViewController {
 
 
     override func viewWillAppear(_ animated: Bool) {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         super.viewWillAppear(animated)
-        // needs to be changed if returning from portSettingsController
-        smtpPortCell.detailTextLabel?.text = DcConfig.sendPort ?? DcConfig.configuredSendPort
-        imapPortCell.detailTextLabel?.text = DcConfig.mailPort ?? DcConfig.configuredMailPort
-        smtpSecurityCell.detailTextLabel?.text = SecurityConverter.convertHexToString(type: .SMTPSecurity, hex: DcConfig.getSmtpSecurity())
-        imapSecurityCell.detailTextLabel?.text  = SecurityConverter.convertHexToString(type: .IMAPSecurity, hex: DcConfig.getImapSecurity())
+        initSelectionCells()
     }
     }
 
 
     override func viewDidAppear(_ animated: Bool) {
     override func viewDidAppear(_ animated: Bool) {
@@ -721,6 +717,26 @@ class AccountSetupController: UITableViewController {
         dismiss(animated: true, completion: nil)
         dismiss(animated: true, completion: nil)
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
         let appDelegate = UIApplication.shared.delegate as! AppDelegate
         appDelegate.registerForPushNotifications()
         appDelegate.registerForPushNotifications()
+        if (!DcConfig.configuredMailPort.isEmpty) {
+            DcConfig.mailPort = DcConfig.configuredMailPort
+        }
+        if (!DcConfig.configuredMailServer.isEmpty) {
+            DcConfig.mailServer = DcConfig.configuredMailServer
+        }
+        if (!DcConfig.configuredSendPort.isEmpty) {
+            DcConfig.sendPort = DcConfig.configuredSendPort
+        }
+        if (!DcConfig.configuredSendServer.isEmpty) {
+            DcConfig.sendServer = DcConfig.configuredSendServer
+        }
+        initSelectionCells();
+    }
+
+    private func initSelectionCells() {
+        smtpPortCell.detailTextLabel?.text = DcConfig.sendPort ?? DcConfig.configuredSendPort
+        imapPortCell.detailTextLabel?.text = DcConfig.mailPort ?? DcConfig.configuredMailPort
+        smtpSecurityCell.detailTextLabel?.text = SecurityConverter.convertHexToString(type: .SMTPSecurity, hex: DcConfig.getSmtpSecurity())
+        imapSecurityCell.detailTextLabel?.text  = SecurityConverter.convertHexToString(type: .IMAPSecurity, hex: DcConfig.getImapSecurity())
     }
     }
 
 
     private func resignFirstResponderOnAllCells() {
     private func resignFirstResponderOnAllCells() {