Skip to content

Commit ce0d7ae

Browse files
Ginder-SinghSoner Yuksel
authored andcommitted
Merge branch 'soner/fix/795-protocol-fail-cancel' into 'main'
Fix #795: Protocol switch timer not cancelling on screen dismiss and memory leak See merge request ws/client/iosapp!1000 (cherry picked from commit 3b03b37)
1 parent fe8bb7d commit ce0d7ae

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Windscribe/Managers/Protocols/ProtocolManager.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ protocol ProtocolManagerType {
3636
func onConnectStateChange(state: NEVPNStatus)
3737
func scheduleTimer()
3838
func saveCurrentWifiNetworks()
39+
func cancelFailoverTimer()
3940
}
4041

4142
class ProtocolManager: ProtocolManagerType {
@@ -455,4 +456,18 @@ extension ProtocolManager {
455456
}
456457
}
457458
}
459+
460+
/// Cancels the failover countdown timer when user dismisses the protocol switch screen
461+
/// This prevents automatic protocol switching after user has dismissed the dialog
462+
func cancelFailoverTimer() {
463+
logger.logI("ProtocolManager", "Failover timer cancelled by user - stopping countdown")
464+
465+
// Reset any nextUp protocols back to normal state
466+
if let nextUpProtocol = protocolsToConnectList.first(where: { $0.viewType.isNextup }) {
467+
setPriority(proto: nextUpProtocol.protocolPort.protocolName, type: .normal)
468+
}
469+
470+
// Stop the timer
471+
stopCountdownTimer()
472+
}
458473
}

Windscribe/Modules/Popup/Connection/ProtocolSwitch/ViewModels/ProtocolSwitchViewModel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,16 @@ final class ProtocolSwitchViewModelImpl: ProtocolSwitchViewModel, ObservableObje
176176
}
177177

178178
func dismiss() {
179+
// Cancel any active failover timer to prevent automatic protocol switching
180+
protocolManager.cancelFailoverTimer()
179181
shouldDismiss = true
180182
}
181183

182184
/// Handles cancel button action based on current connection state
183185
func cancelSelection() {
186+
// Always cancel any active failover timer when user cancels
187+
protocolManager.cancelFailoverTimer()
188+
184189
if vpnManager.isConnected() {
185190
// Connected state - just dismiss the dialog
186191
logger.logI("ProtocolSwitchViewModel", "Canceling protocol selection - connected")

0 commit comments

Comments
 (0)