Skip to content

Commit

Permalink
fix: notification clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
ohaiibuzzle committed Jan 13, 2024
1 parent 8773900 commit b87bc2f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions USBNotifier/Core/USBDetector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,17 @@ class USBDetector {
return devices
}

func clearNotifications() {
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
}

private func sendNotifications(for device: USBDevice,
status: USBConnectionStatus,
sound: Bool = false) {
if Storage.shared.ephemeralNotifs {
clearNotifications()
}

let notificationContent = UNMutableNotificationContent()
switch status {
case .connected:
Expand All @@ -112,10 +120,6 @@ class USBDetector {
}
}

func clearNotifications() {
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
}

private func sendNotifications(for devices: [USBDevice],
status: USBConnectionStatus,
sound: Bool = false) {
Expand All @@ -130,6 +134,11 @@ class USBDetector {
}
}

// If the user choosed to have the notification clears themselves, do it
if Storage.shared.ephemeralNotifs {
clearNotifications()
}

let notificationContent = UNMutableNotificationContent()
switch status {
case .connected:
Expand Down

0 comments on commit b87bc2f

Please sign in to comment.