B. Petersen 5 жил өмнө
parent
commit
9436395793

+ 8 - 2
deltachat-ios/Controller/SettingsAutodelOverviewController.swift

@@ -24,7 +24,7 @@ class SettingsAutodelOverviewController: UITableViewController {
         cell.tag = CellTags.autodelDevice.rawValue
         cell.tag = CellTags.autodelDevice.rawValue
         cell.textLabel?.text = String.localized("autodel_device_title")
         cell.textLabel?.text = String.localized("autodel_device_title")
         cell.accessoryType = .disclosureIndicator
         cell.accessoryType = .disclosureIndicator
-        cell.detailTextLabel?.text = autodelSummary()
+        cell.detailTextLabel?.text = SettingsAutodelSetController.getSummary(dcContext, fromServer: false)
         return cell
         return cell
     }()
     }()
 
 
@@ -33,7 +33,7 @@ class SettingsAutodelOverviewController: UITableViewController {
         cell.tag = CellTags.autodelServer.rawValue
         cell.tag = CellTags.autodelServer.rawValue
         cell.textLabel?.text = String.localized("autodel_server_title")
         cell.textLabel?.text = String.localized("autodel_server_title")
         cell.accessoryType = .disclosureIndicator
         cell.accessoryType = .disclosureIndicator
-        cell.detailTextLabel?.text = autodelSummary()
+        cell.detailTextLabel?.text = SettingsAutodelSetController.getSummary(dcContext, fromServer: true)
         return cell
         return cell
     }()
     }()
 
 
@@ -61,6 +61,12 @@ class SettingsAutodelOverviewController: UITableViewController {
         super.viewDidLoad()
         super.viewDidLoad()
     }
     }
 
 
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        autodelDeviceCell.detailTextLabel?.text = SettingsAutodelSetController.getSummary(dcContext, fromServer: false)
+        autodelServerCell.detailTextLabel?.text = SettingsAutodelSetController.getSummary(dcContext, fromServer: true)
+    }
+
     // MARK: - Table view data source
     // MARK: - Table view data source
 
 
     override func numberOfSections(in tableView: UITableView) -> Int {
     override func numberOfSections(in tableView: UITableView) -> Int {

+ 11 - 5
deltachat-ios/Controller/SettingsAutodelSetController.swift

@@ -9,7 +9,7 @@ class SettingsAutodelSetController: UITableViewController {
         let descr: String
         let descr: String
     }
     }
 
 
-    private lazy var autodelDeviceOptions: [Options] = {
+    private static let autodelDeviceOptions: [Options] = {
         return [
         return [
             Options(value: 0, descr: "off"),
             Options(value: 0, descr: "off"),
             Options(value: 3600, descr: "autodel_after_1_hour"),
             Options(value: 3600, descr: "autodel_after_1_hour"),
@@ -19,7 +19,7 @@ class SettingsAutodelSetController: UITableViewController {
         ]
         ]
     }()
     }()
 
 
-    private lazy var autodelServerOptions: [Options] = {
+    private static let autodelServerOptions: [Options] = {
         return [
         return [
             Options(value: 0, descr: "off"),
             Options(value: 0, descr: "off"),
             Options(value: 1, descr: "autodel_at_once"),
             Options(value: 1, descr: "autodel_at_once"),
@@ -31,7 +31,7 @@ class SettingsAutodelSetController: UITableViewController {
     }()
     }()
 
 
     private lazy var autodelOptions: [Options] = {
     private lazy var autodelOptions: [Options] = {
-        return fromServer ? autodelServerOptions : autodelDeviceOptions
+        return fromServer ? SettingsAutodelSetController.autodelServerOptions : SettingsAutodelSetController.autodelDeviceOptions
     }()
     }()
 
 
     var fromServer: Bool
     var fromServer: Bool
@@ -76,8 +76,14 @@ class SettingsAutodelSetController: UITableViewController {
         navigationItem.rightBarButtonItem = okButton
         navigationItem.rightBarButtonItem = okButton
     }
     }
 
 
-    static public func getAutodelString(fromServer: Bool, val: Int) -> String {
-        // TODO
+    static public func getSummary(_ dcContext: DcContext, fromServer: Bool) -> String {
+        let val = dcContext.getConfigInt(fromServer ? "delete_server_after" :  "delete_device_after")
+        let options = fromServer ? SettingsAutodelSetController.autodelServerOptions : SettingsAutodelSetController.autodelDeviceOptions
+        for option in options {
+            if option.value == val {
+                return String.localized(option.descr)
+            }
+        }
         return "Err"
         return "Err"
     }
     }