Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

The Reset sheet sees a menu bar app open and quit

Țugui Dragoșf443eaaa1f4f
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index 4d0d7939..03a00e0e 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -52,11 +52,9 @@ struct ResetSheet: View {
.task(id: exclusions.revision) {
await plan.refresh(installedApps: library.apps)
}
- // A reset needs the app quit, so the sheet follows the app launching or quitting while it is open.
- .onReceive(NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didLaunchApplicationNotification)) { _ in
- plan.refreshRunningState()
- }
- .onReceive(NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didTerminateApplicationNotification)) { _ in
+ // A reset needs the app quit, so the sheet follows the apps that run. The workspace reports every change
+ // to them through key-value observing, while it posts no notice for a menu bar or background app.
+ .onReceive(NSWorkspace.shared.publisher(for: \.runningApplications)) { _ in
plan.refreshRunningState()
}
}
diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swift
index 7f65b3da..cf7bdaa7 100644
--- a/Peel/Views/Settings/SavedSettingsSection.swift
+++ b/Peel/Views/Settings/SavedSettingsSection.swift
@@ -31,10 +31,9 @@ struct SavedSettingsSection: View {
}
}
.task { reload() }
- .onReceive(NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didLaunchApplicationNotification)) { _ in
- refreshOpenApps()
- }
- .onReceive(NSWorkspace.shared.notificationCenter.publisher(for: NSWorkspace.didTerminateApplicationNotification)) { _ in
+ // Put Back waits for the app to quit. The workspace reports every change to the apps that run through
+ // key-value observing, while it posts no notice for a menu bar or background app.
+ .onReceive(NSWorkspace.shared.publisher(for: \.runningApplications)) { _ in
refreshOpenApps()
}
.confirmationDialog(trashQuestion, isPresented: isAskingToTrash, presenting: copyToTrash) { copy in