Ver Fonte

added callback that is called when PortSettingsController is dismissed to update with core

Bastian van de Wetering há 6 anos atrás
pai
commit
bed7a758b8

+ 7 - 1
deltachat-ios/Controller/AccountSetup/PortSettingsController.swift

@@ -16,9 +16,11 @@ class PortSettingsController: UITableViewController {
 
 	var resetButton: UIBarButtonItem!
 
+	var onDismiss:((String)->Void)?
+
 	var currentPort: Int {
 		didSet {
-			// activate resetButton
+			// activate resetButton once something was changed
 			resetButton.isEnabled = true
 		}
 	}
@@ -69,6 +71,10 @@ class PortSettingsController: UITableViewController {
 		resetButton.isEnabled = false
 	}
 
+	override func viewWillDisappear(_ animated: Bool) {
+		onDismiss?("\(currentPort)")
+	}
+
 	// MARK: - Table view data source
 
 	override func numberOfSections(in tableView: UITableView) -> Int {

+ 10 - 0
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -212,6 +212,11 @@ class AccountSetupCoordinator: Coordinator {
 		let currentMailPort = MRConfig.mailPort ?? MRConfig.configuredMailPort
 		let currentPort = Int(currentMailPort)
 		let portSettingsController = PortSettingsController(sectionTitle: "IMAP Port", ports: [143, 993], currentPort: currentPort)
+		portSettingsController.onDismiss = {
+			port in
+			MRConfig.mailPort = port
+			dc_configure(mailboxPointer)
+		}
 		navigationController.pushViewController(portSettingsController, animated: true)
 	}
 
@@ -223,6 +228,11 @@ class AccountSetupCoordinator: Coordinator {
 		let currentMailPort = MRConfig.sendPort ?? MRConfig.configuredSendPort
 		let currentPort = Int(currentMailPort)
 		let portSettingsController = PortSettingsController(sectionTitle: "SMTP Port", ports: [25, 465, 587], currentPort: currentPort)
+		portSettingsController.onDismiss = {
+			port in
+			MRConfig.sendPort = port
+			dc_configure(mailboxPointer)
+		}
 		navigationController.pushViewController(portSettingsController, animated: true)
 	}