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
Open the list when a notification names several updates
Țugui Dragoșe21839c6f7d4
diff --git a/Peel/Model/PeelNotifications.swift b/Peel/Model/PeelNotifications.swiftindex e716c7a0..3636f5e5 100644--- a/Peel/Model/PeelNotifications.swift+++ b/Peel/Model/PeelNotifications.swift@@ -8,6 +8,9 @@ final class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {nonisolated static let pathKey = "path"nonisolated static let toolKey = "tool"+ /// The list of apps, whose chosen row a click that opens the whole list clears.+ var appList: AppLibrary?+func activate() {UNUserNotificationCenter.current().delegate = self}@@ -72,7 +75,10 @@ final class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {? String(localized: "\(firstName) has an update"): String(inflecting: "^[\(count) app](inflect: true) have new updates")content.body = String(localized: "Peel doesn’t install updates on its own. Click to see what’s waiting, under Applications.")- content.userInfo = [Self.pathKey: firstApp.path(percentEncoded: false)]+ // One update opens that app's page, where it is updated. Several open the list, which leads with them, rather+ // than one app's page with its files selected for removal.+ content.userInfo = count == 1+ ? [Self.pathKey: firstApp.path(percentEncoded: false)] : [Self.toolKey: Tool.applications.rawValue]return content}@@ -83,6 +89,7 @@ final class PeelNotifications: NSObject, UNUserNotificationCenterDelegate {Navigator.shared.requestedApp = URL(filePath: path, directoryHint: .isDirectory)Navigator.shared.show(.applications)} else if let tool = tool.flatMap(Tool.init(rawValue:)) {+ if tool == .applications { appList?.selection = [] }Navigator.shared.show(tool)}}diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swiftindex 8962899a..697d57d9 100644--- a/Peel/PeelApp.swift+++ b/Peel/PeelApp.swift@@ -100,6 +100,7 @@ struct PeelApp: App {let selfUninstall = SelfUninstall()_selfUninstall = State(initialValue: selfUninstall)let library = AppLibrary()+ notifications.appList = library_homebrew = State(initialValue: HomebrewLibrary(appsOfCask: { [library] in library.apps(of: $0) }))let history = RemovalHistoryStore(outcome: outcome, removesPeel: { selfUninstall.isRunning })let (orphans, space, developer, projects) = (diff --git a/PeelTests/NotificationClickTests.swift b/PeelTests/NotificationClickTests.swiftindex bb35fea7..35a8aa7b 100644--- a/PeelTests/NotificationClickTests.swift+++ b/PeelTests/NotificationClickTests.swift@@ -24,4 +24,27 @@ import UserNotifications#expect(Navigator.shared.requestedApp == app)#expect(Navigator.shared.requestedTool == .applications)}++ @Test func severalUpdatesOpenTheListWithNoAppChosen() throws {+ defer {+ Navigator.shared.requestedApp = nil+ Navigator.shared.requestedTool = nil+ }+ let madeUp = try MadeUpDefaults()+ defer { madeUp.forget() }+ let library = AppLibrary(defaults: madeUp.defaults)+ let app = InstalledApp(+ url: URL(filePath: "/Applications/Example.app", directoryHint: .isDirectory),+ bundleIdentifier: "org.example.app", name: "Example"+ )+ library.selection = [app.id]+ let notifications = PeelNotifications()+ notifications.appList = library++ click(PeelNotifications.updatesContent(count: 3, firstName: "Example", firstApp: app.url), on: notifications)++ #expect(Navigator.shared.requestedApp == nil)+ #expect(Navigator.shared.requestedTool == .applications)+ #expect(library.selection.isEmpty)+ }}