Skip to content

Commit

Permalink
when using chatmail, the only reasonable delete-from-server-options a…
Browse files Browse the repository at this point in the history
…re delete-once and automatic (as the chatmail server deletetes from server anyways at some point)
  • Loading branch information
r10s committed Oct 18, 2024
1 parent c2ba4cf commit 4c1a9fa
Showing 1 changed file with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,27 @@ class AutodelOptionsViewController: UITableViewController {
]
}()

private static let autodelServerOptions: [Options] = {
return [
Options(value: 0, descr: "never"),
Options(value: 1, descr: "autodel_at_once"),
Options(value: 60 * 60, descr: "autodel_after_1_hour"),
Options(value: 24 * 60 * 60, descr: "autodel_after_1_day"),
Options(value: 7 * 24 * 60 * 60, descr: "autodel_after_1_week"),
Options(value: 5 * 7 * 24 * 60 * 60, descr: "after_5_weeks"),
Options(value: 365 * 24 * 60 * 60, descr: "autodel_after_1_year"),
]
}()
private static func autodelServerOptions(_ dcContext: DcContext) -> [Options] {
if dcContext.isChatmail {
return [
Options(value: 0, descr: "automatic"),
Options(value: 1, descr: "autodel_at_once"),
]
} else {
return [
Options(value: 0, descr: "never"),
Options(value: 1, descr: "autodel_at_once"),
Options(value: 60 * 60, descr: "autodel_after_1_hour"),
Options(value: 24 * 60 * 60, descr: "autodel_after_1_day"),
Options(value: 7 * 24 * 60 * 60, descr: "autodel_after_1_week"),
Options(value: 5 * 7 * 24 * 60 * 60, descr: "after_5_weeks"),
Options(value: 365 * 24 * 60 * 60, descr: "autodel_after_1_year"),
]
}
}

private lazy var autodelOptions: [Options] = {
return fromServer ? AutodelOptionsViewController.autodelServerOptions : AutodelOptionsViewController.autodelDeviceOptions
return fromServer ? AutodelOptionsViewController.autodelServerOptions(dcContext) : AutodelOptionsViewController.autodelDeviceOptions
}()

var fromServer: Bool
Expand Down Expand Up @@ -80,7 +87,7 @@ class AutodelOptionsViewController: UITableViewController {

static public func getSummary(_ dcContext: DcContext, fromServer: Bool) -> String {
let val = dcContext.getConfigInt(fromServer ? "delete_server_after" : "delete_device_after")
let options = fromServer ? AutodelOptionsViewController.autodelServerOptions : AutodelOptionsViewController.autodelDeviceOptions
let options = fromServer ? AutodelOptionsViewController.autodelServerOptions(dcContext) : AutodelOptionsViewController.autodelDeviceOptions
for option in options {
if option.value == val {
return String.localized(option.descr)
Expand Down

0 comments on commit 4c1a9fa

Please sign in to comment.