Skip to content

Commit

Permalink
Update the way we cancel snooze.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsymons committed Jul 9, 2024
1 parent cc0bd6d commit 14f513b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Sources/NetworkProtection/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1697,16 +1697,16 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
}

private func cancelSnooze() async {
guard snoozeTimingStore.activeTiming != nil else {
assertionFailure("Tried to cancel snooze when it was not active")
snoozeTimer?.cancel()
snoozeTimer = nil

guard await connectionStatus == .snoozing, snoozeTimingStore.activeTiming != nil else {
os_log("Failed to cancel snooze mode as it was not active", log: .networkProtection, type: .error)
return
}

os_log("Canceling snooze mode", log: .networkProtection)

snoozeTimer?.cancel()
snoozeTimer = nil

snoozeJustEnded = true
snoozeTimingStore.reset()
try? await startTunnel(onDemand: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final public class NetworkProtectionSnoozeTimingStore {
let startDate: Date
let duration: TimeInterval

var endDate: Date {
public var endDate: Date {
return startDate.addingTimeInterval(duration)
}
}
Expand All @@ -35,7 +35,7 @@ final public class NetworkProtectionSnoozeTimingStore {
private let userDefaults: UserDefaults
private let notificationCenter: NotificationCenter

public init(userDefaults: UserDefaults = .standard, notificationCenter: NotificationCenter = .default) {
public init(userDefaults: UserDefaults, notificationCenter: NotificationCenter = .default) {
self.userDefaults = userDefaults
self.notificationCenter = notificationCenter
}
Expand Down

0 comments on commit 14f513b

Please sign in to comment.