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 looks again when it comes forward
Țugui Dragoș2f6dbd1f8132
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swiftindex bef0c4eb..02a1ced6 100644--- a/Peel/Model/AppLibrary.swift+++ b/Peel/Model/AppLibrary.swift@@ -166,7 +166,7 @@ final class AppLibrary {await AppMemory().remember(found)}- /// Calls `refresh()` unless the folders were read in the last 30 seconds. For the window coming forward:+ /// Calls `refresh()` unless the folders were read in the last 30 seconds. For Peel coming forward:/// the folder watcher sees every real change, so a recent read is enough.func refreshUnlessRecent() async -> [InstalledApp] {if let lastRead, ContinuousClock.now - lastRead < .seconds(30) { return [] }diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swiftindex 76e00aef..1ad2e16e 100644--- a/Peel/PeelApp.swift+++ b/Peel/PeelApp.swift@@ -14,7 +14,6 @@ final class PeelAppDelegate: NSObject, NSApplicationDelegate {@mainstruct PeelApp: App {@NSApplicationDelegateAdaptor(PeelAppDelegate.self) private var delegate- @Environment(\.scenePhase) private var scenePhasestatic let mainWindowID = "main"/// How often the update round runs. The shortest wait an app can have is six hours, after a failed check/// (`UpdateSchedule.afterFailure`), so an hourly round checks each app soon after it is due.@@ -119,6 +118,31 @@ struct PeelApp: App {}}+ /// Looks again, each time Peel comes forward, at what may have changed while another app was in front. A+ /// window's scene phase is no sign of that: on macOS a window stays active while another app is in front.+ private func followActivations() async {+ for await _ in NotificationCenter.default.notifications(named: NSApplication.didBecomeActiveNotification) {+ helper.refresh()+ // Home's checks run again whatever page is showing: permissions change in System Settings, and the+ // badge on Home in the sidebar shows a missing one.+ Task { await home.refresh(helper: helper) }+ Task {+ // Whichever read finds a changed bundle checks it again. When two reads overlap, only the newer+ // one reports what changed, and it may be this one rather than the folder watcher's.+ let changed = await library.refreshUnlessRecent()+ if checksForAppUpdates, !changed.isEmpty {+ await library.checkForUpdates(changed, force: true)+ }+ if !changed.isEmpty {+ await library.checkSigningTeams()+ }+ }+ if watchesTrash, trashMonitor.status == .needsFullDiskAccess {+ trashMonitor.start()+ }+ }+ }+/// Records what each tool finds, its page open or not, so Home can list it. Each tool is followed on its own, so/// one that looks again leaves the others' dates as they were.private func followFindings() async {@@ -221,7 +245,7 @@ struct PeelApp: App {await HomeSnapshot.runIfRequested()#endif// While Peel watches the Trash it keeps running after its window closes, so reopening the window- // must not run the launch work again. Work for a window coming forward is in `scenePhase` below.+ // must not run the launch work again. Work for Peel coming forward is in `followActivations`.guard !hasLaunched else { return }hasLaunched = truehistory.stats = stats@@ -251,35 +275,13 @@ struct PeelApp: App {.task {// Started once, and not as a child of this view's task, so the work goes on in the menu bar// after the window closes.- background.start([followFolders, askWhenDue, followFindings])+ background.start([followFolders, askWhenDue, followFindings, followActivations])}}.defaultSize(width: 1120, height: 764).commands {PeelCommands(library: library, homebrew: homebrew)}- .onChange(of: scenePhase) { _, phase in- if phase == .active {- helper.refresh()- // Home's checks run again whatever page is showing: permissions change in System Settings, and the- // badge on Home in the sidebar shows a missing one.- Task { await home.refresh(helper: helper) }- Task {- // Whichever read finds a changed bundle checks it again. When two reads overlap, only the newer- // one reports what changed, and it may be this one rather than the folder watcher's.- let changed = await library.refreshUnlessRecent()- if checksForAppUpdates, !changed.isEmpty {- await library.checkForUpdates(changed, force: true)- }- if !changed.isEmpty {- await library.checkSigningTeams()- }- }- if watchesTrash, trashMonitor.status == .needsFullDiskAccess {- trashMonitor.start()- }- }- }.onChange(of: watchesTrash) { _, isWatching inif isWatching {trashMonitor.start()diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swiftindex a65b39ce..570fdfc8 100644--- a/Peel/Views/Settings/SettingsView.swift+++ b/Peel/Views/Settings/SettingsView.swift@@ -86,7 +86,6 @@ private struct GeneralSettingsView: View {@AppStorage(SettingsKey.watchesTrash) private var watchesTrash = false@AppStorage(SettingsKey.hiddenTools) private var hiddenTools = ""@Environment(TrashMonitor.self) private var trashMonitor- @Environment(\.scenePhase) private var scenePhase@Environment(AppLibrary.self) private var library@Environment(HomebrewLibrary.self) private var homebrew@Environment(HelperModel.self) private var helper@@ -311,9 +310,9 @@ private struct GeneralSettingsView: View {Task { await library.checkForUpdates(library.apps) }}.task { readStandings() }- .onChange(of: scenePhase) { _, phase in+ .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in// The user may have changed the login item in System Settings, so read it again.- if phase == .active { readStandings() }+ readStandings()}.confirmationDialog("Remove Peel from this Mac?", isPresented: $isConfirmingSelfRemoval) {Button("Remove Peel", role: .destructive) {