Skip to content

Commit

Permalink
Delete proxies (#2382)
Browse files Browse the repository at this point in the history
For whatever reasons this doesn't work in the simulator. Will investigate further, but it took me some time to figure that out.
  • Loading branch information
zeitschlag committed Nov 6, 2024
1 parent bc2b3aa commit c1e56bd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class ProxySettingsViewController: UIViewController {
if dcContext.setConfigFromQR(qrCode: selectedProxyURL) {
self.selectedProxy = selectedProxyURL
tableView.reloadData()
dcAccounts.stopIo()
dcAccounts.startIo()
dcAccounts.restartIO()
}
}

Expand Down Expand Up @@ -161,12 +160,14 @@ extension ProxySettingsViewController: UITableViewDataSource {

if proxies.isEmpty {
if indexPath.section == ProxySettingsSection.enableProxies.rawValue {
toggleProxyCell.uiSwitch.isOn = dcContext.isProxyEnabled
return toggleProxyCell
} else /* if indexPath.section == ProxySettingsSection.add.rawValue */ {
return addProxyCell
}
} else {
if indexPath.section == ProxySettingsSection.enableProxies.rawValue {
toggleProxyCell.uiSwitch.isOn = dcContext.isProxyEnabled
return toggleProxyCell
} else if indexPath.section == ProxySettingsSection.proxies.rawValue {
guard let cell = tableView.dequeueReusableCell(withIdentifier: ProxyTableViewCell.reuseIdentifier, for: indexPath) as? ProxyTableViewCell else { fatalError() }
Expand All @@ -181,7 +182,6 @@ extension ProxySettingsViewController: UITableViewDataSource {
}

return cell
// ProxyCell with proxies[indexPath.row]
} else /*if indexPath.section == ProxySettingsSection.add.rawValue*/ {
return addProxyCell
}
Expand Down Expand Up @@ -211,4 +211,27 @@ extension ProxySettingsViewController: UITableViewDelegate {

tableView.deselectRow(at: indexPath, animated: true)
}

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
guard
proxies.isEmpty == false,
indexPath.section == ProxySettingsSection.proxies.rawValue
else { return nil }

let deleteAction = UIContextualAction(style: .destructive, title: String.localized("proxy_delete")) { [weak self] _, _, completion in
self?.deleteProxy(at: indexPath)
DispatchQueue.main.async {
self?.tableView.reloadData()
completion(true)
}
}
deleteAction.backgroundColor = .red
deleteAction.image = UIImage(named: "ic_trash")

let configuration = UISwipeActionsConfiguration(actions: [deleteAction])
configuration.performsFirstActionWithFullSwipe = true

return configuration
}

}
5 changes: 5 additions & 0 deletions deltachat-ios/DC/DcAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public class DcAccounts {
dc_accounts_stop_io(accountsPointer)
}

public func restartIO() {
stopIo()
startIo()
}

public func backgroundFetch(timeout: UInt64) -> Bool {
return dc_accounts_background_fetch(accountsPointer, timeout) == 1
}
Expand Down

0 comments on commit c1e56bd

Please sign in to comment.