summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-03-11 09:05:26 +0100
committerBug Magnet <marco.nikic@mullvad.net>2024-03-11 09:05:26 +0100
commitf89c0e885bac729fd2f1341767228db0d0c4d48c (patch)
tree8879c8329de5b56742ce767a42fa15a2dbc0ffc0
parent9c035eedaea92216b6b5be4bf2fe0ca25fe9f257 (diff)
parent8dbe9cb12690f4804a650abbeb8009e521f7ab80 (diff)
downloadmullvadvpn-f89c0e885bac729fd2f1341767228db0d0c4d48c.tar.xz
mullvadvpn-f89c0e885bac729fd2f1341767228db0d0c4d48c.zip
Merge branch 'make-the-clear-all-overrides-button-only-active-when-there-ios-547'
-rw-r--r--ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideInteractor.swift13
-rw-r--r--ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideStatus.swift2
-rw-r--r--ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideViewController.swift1
3 files changed, 12 insertions, 4 deletions
diff --git a/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideInteractor.swift b/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideInteractor.swift
index 75264eaf30..13584cc712 100644
--- a/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideInteractor.swift
+++ b/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideInteractor.swift
@@ -11,10 +11,11 @@ import MullvadLogging
import MullvadSettings
import MullvadTypes
-struct IPOverrideInteractor {
+final class IPOverrideInteractor {
private let logger = Logger(label: "IPOverrideInteractor")
private let repository: IPOverrideRepositoryProtocol
private let tunnelManager: TunnelManager
+ private var statusWorkItem: DispatchWorkItem?
private let statusSubject = CurrentValueSubject<IPOverrideStatus, Never>(.noImports)
var statusPublisher: AnyPublisher<IPOverrideStatus, Never> {
@@ -87,8 +88,14 @@ struct IPOverrideInteractor {
}
private func resetToDefaultStatus(delay: Duration = .zero) {
- DispatchQueue.main.asyncAfter(deadline: .now() + delay.timeInterval) {
- statusSubject.send(defaultStatus)
+ statusWorkItem?.cancel()
+
+ let statusWorkItem = DispatchWorkItem { [weak self] in
+ guard let self, self.statusWorkItem?.isCancelled == false else { return }
+ self.statusSubject.send(self.defaultStatus)
}
+ self.statusWorkItem = statusWorkItem
+
+ DispatchQueue.main.asyncAfter(deadline: .now() + delay.timeInterval, execute: statusWorkItem)
}
}
diff --git a/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideStatus.swift b/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideStatus.swift
index 85cc8d3fc5..42e03e8c76 100644
--- a/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideStatus.swift
+++ b/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideStatus.swift
@@ -8,7 +8,7 @@
import UIKit
-enum IPOverrideStatus: CustomStringConvertible {
+enum IPOverrideStatus: Equatable, CustomStringConvertible {
case active, noImports, importSuccessful(Context), importFailed(Context)
enum Context {
diff --git a/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideViewController.swift b/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideViewController.swift
index 8bce36d450..5f8021d4e0 100644
--- a/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideViewController.swift
+++ b/ios/MullvadVPN/Coordinators/Settings/IPOverride/IPOverrideViewController.swift
@@ -66,6 +66,7 @@ class IPOverrideViewController: UIViewController {
interactor.statusPublisher.sink { [weak self] status in
self?.statusView.setStatus(status)
+ self?.clearButton.isEnabled = self?.interactor.defaultStatus == .active
}.store(in: &cancellables)
}