Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Peel's notifications stay in Notification Center while Peel is in front
Țugui Dragoș7e6848332149
diff --git a/Packages/PeelCore/Sources/PeelCore/Support/NotificationPresentation.swift b/Packages/PeelCore/Sources/PeelCore/Support/NotificationPresentation.swiftnew file mode 100644index 00000000..f8b09d57--- /dev/null+++ b/Packages/PeelCore/Sources/PeelCore/Support/NotificationPresentation.swift@@ -0,0 +1,9 @@+public import UserNotifications++/// How a notice of Peel's is shown. It always goes to Notification Center, so the outcome of work that ended on a+/// page the person has left can still be read, and it is a banner only while Peel is not in front.+public enum NotificationPresentation {+ public static func options(whilePeelIsActive isActive: Bool) -> UNNotificationPresentationOptions {+ isActive ? [.list] : [.banner, .list]+ }+}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/NotificationPresentationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/NotificationPresentationTests.swiftnew file mode 100644index 00000000..f3a98e7b--- /dev/null+++ b/Packages/PeelCore/Tests/PeelCoreTests/NotificationPresentationTests.swift@@ -0,0 +1,12 @@+@testable import PeelCore+import Testing+import UserNotifications++struct NotificationPresentationTests {+ /// A notice stays in Notification Center whatever is in front, and shows as a banner only while Peel is not,+ /// since its window already says what the banner would.+ @Test func keepsEveryNoticeAndShowsABannerOnlyBehindAnotherApp() {+ #expect(NotificationPresentation.options(whilePeelIsActive: true) == [.list])+ #expect(NotificationPresentation.options(whilePeelIsActive: false) == [.banner, .list])+ }+}diff --git a/Peel/Model/PeelNotifications.swift b/Peel/Model/PeelNotifications.swiftindex 7f22fdbd..65ac94a0 100644--- a/Peel/Model/PeelNotifications.swift+++ b/Peel/Model/PeelNotifications.swift@@ -73,8 +73,7 @@ final class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {_ center: UNUserNotificationCenter,willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {- // No banner while Peel is the active app: the user is already looking at its window.- await MainActor.run { NSApp.isActive ? [] : [.banner] }+ await MainActor.run { NotificationPresentation.options(whilePeelIsActive: NSApp.isActive) }}nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {