Skip to content

Commit

Permalink
Properly delete proxies (#2382)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Nov 7, 2024
1 parent c1e56bd commit a0ad969
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ class ProxySettingsViewController: UIViewController {
}

private func deleteProxy(at indexPath: IndexPath) {
// TODO: Delete Proxy, if proxy was selected: Deselect proxy
let proxyToRemove = proxies[indexPath.row]

if let selectedProxy, proxyToRemove == selectedProxy {
dcContext.isProxyEnabled = false
}

proxies.remove(at: indexPath.row)
toggleProxyCell.uiSwitch.isEnabled = (proxies.isEmpty == false)
dcContext.setProxies(proxyURLs: proxies)
tableView.reloadData()
}
}

Expand Down Expand Up @@ -219,9 +228,8 @@ extension ProxySettingsViewController: UITableViewDelegate {
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()
self?.deleteProxy(at: indexPath)
completion(true)
}
}
Expand Down

0 comments on commit a0ad969

Please sign in to comment.