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
An app's page scans again for an exclusion change only once
Țugui Dragoșf8effa74569b
diff --git a/Peel/Model/BulkRemovalPlan.swift b/Peel/Model/BulkRemovalPlan.swiftindex c716b5e5..e7e8b6ff 100644--- a/Peel/Model/BulkRemovalPlan.swift+++ b/Peel/Model/BulkRemovalPlan.swift@@ -64,19 +64,24 @@ final class BulkRemovalPlan {bulk?.staying(selected: selectedURLs) ?? []}+ /// The revision of the exclusions the last scan read, nil before the first.+ private(set) var exclusionsRevision: Int?+func refresh(installedApps: [InstalledApp], canUseHelper: Bool, casks: [HomebrewPackage] = [], receipts: Set<String> = []) async {self.canUseHelper = canUseHelperlet apps = apps- guard let result = await scanRun.run({- await BulkUninstallation.prepare(+ guard let (result, revision) = await scanRun.run({+ let revision = ExclusionsStore.shared.revision+ return (await BulkUninstallation.prepare(apps,installedApps: installedApps,exclusions: ExclusionsStore.shared.exclusions,casks: casks,receipts: receipts- )+ ), revision)}) else { return }bulk = result+ exclusionsRevision = revisionself.installedApps = installedAppsselectedURLs = choices.update(selectedURLs, in: result, canUseHelper: self.canUseHelper)}diff --git a/Peel/Model/RemovalPlan.swift b/Peel/Model/RemovalPlan.swiftindex 2548c980..47e72493 100644--- a/Peel/Model/RemovalPlan.swift+++ b/Peel/Model/RemovalPlan.swift@@ -88,10 +88,14 @@ final class RemovalPlan {/// What a checkbox can select now.var selectable: Set<URL> { choices.selectable }+ /// The revision of the exclusions the last scan read, nil before the first.+ private(set) var exclusionsRevision: Int?+func refresh(installedApps: [InstalledApp], canUseHelper: Bool, casks: [HomebrewPackage] = [], receipts: Set<String> = []) async {self.canUseHelper = canUseHelperlet app = app- guard let (result, bundle) = await scanRun.run({+ guard let (result, bundle, revision) = await scanRun.run({+ let revision = ExclusionsStore.shared.revisionlet result = await Uninstallation.prepare(app,installedApps: installedApps,@@ -99,9 +103,10 @@ final class RemovalPlan {casks: casks,receipts: receipts)- return (result, await Self.look(inside: app))+ return (result, await Self.look(inside: app), revision)}) else { return }uninstallation = result+ exclusionsRevision = revisionlet leftovers = result.scan.leftoversrecommended = leftovers.filter(\.match.isRecommended)needsReview = leftovers.filter { !$0.match.isRecommended }diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex 9cd73e9d..c867741e 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -81,7 +81,7 @@ struct AppDetailView: View {.task(id: plan.app.url) {hasDockTile = !(await DockTiles().holding([plan.app.url])).isEmpty}- .rescanOnExclusionChange("AppDetailView") { await rescan() }+ .rescanOnExclusionChange(scannedUnder: plan.exclusionsRevision) { await rescan() }.onChange(of: helper.canAct) { _, canAct inplan.follow(canUseHelper: canAct)}diff --git a/Peel/Views/ExclusionRescan.swift b/Peel/Views/ExclusionRescan.swiftindex ed9191fd..92cd79dc 100644--- a/Peel/Views/ExclusionRescan.swift+++ b/Peel/Views/ExclusionRescan.swift@@ -1,15 +1,35 @@import SwiftUIextension View {- /// Scans again when the exclusions change.+ /// Scans again when the exclusions change, for a tool's page, whose findings its library keeps.////// A scan is filtered by the exclusions as they stand when it runs, so after a change an item just excluded/// is still listed, and one taken off the list is still missing. The store remembers which revision each- /// page last scanned under, because Settings takes the whole pane, and while it is open no tool's page is on- /// screen to notice. Duplicates and File Search don't use this, since they scan only when the user asks.+ /// tool's page last scanned under, because Settings takes the whole pane, and while it is open no tool's page+ /// is on screen to notice. Duplicates and File Search don't use this, since they scan only when the user asks.func rescanOnExclusionChange(_ page: String, _ rescan: @escaping () async -> Void) -> some View {modifier(ExclusionRescan(page: page, rescan: rescan))}++ /// Scans again when the exclusions change, for a page whose findings are made with it and go with it, such as+ /// an app's page: `scannedUnder` is the revision its last scan read, nil before its first, so a page made after a+ /// change scans once, under the exclusions as they are.+ func rescanOnExclusionChange(scannedUnder revision: Int?, _ rescan: @escaping () async -> Void) -> some View {+ modifier(PageExclusionRescan(scannedUnder: revision, rescan: rescan))+ }+}++private struct PageExclusionRescan: ViewModifier {+ @Environment(ExclusionsStore.self) private var exclusions+ let scannedUnder: Int?+ let rescan: () async -> Void++ func body(content: Content) -> some View {+ content.task(id: exclusions.revision) {+ guard let scannedUnder, scannedUnder != exclusions.revision else { return }+ await rescan()+ }+ }}private struct ExclusionRescan: ViewModifier {diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swiftindex 99cfd7cc..2aa92656 100644--- a/Peel/Views/MultipleAppsView.swift+++ b/Peel/Views/MultipleAppsView.swift@@ -136,7 +136,7 @@ struct MultipleAppsView: View {.task(id: plan.apps.map(\.url)) {appsInTheDock = await DockTiles().holding(plan.apps.map(\.url))}- .rescanOnExclusionChange("MultipleAppsView") { await rescan() }+ .rescanOnExclusionChange(scannedUnder: plan.exclusionsRevision) { await rescan() }.onChange(of: helper.canAct) { _, canAct inplan.follow(canUseHelper: canAct)}diff --git a/Peel/Views/VendorNotes.swift b/Peel/Views/VendorNotes.swiftindex aa325f0a..e04b03e5 100644--- a/Peel/Views/VendorNotes.swift+++ b/Peel/Views/VendorNotes.swift@@ -45,6 +45,8 @@ struct PackageReceiptSection: View {@State private var filesOutside: [PackageReceipt.ID: [PackageReceipt.Item]] = [:]@State private var receiptToForget: PackageReceipt?@State private var isForgetting = false+ /// The revision of the exclusions the last load read, nil before the first.+ @State private var loadedUnder: Int?var body: some View {Group {@@ -62,12 +64,14 @@ struct PackageReceiptSection: View {}}.task(id: app.id) { await load() }- .rescanOnExclusionChange("VendorNotes") { await load() }+ .rescanOnExclusionChange(scannedUnder: loadedUnder) { await load() }.forgetReceiptDialog(for: $receiptToForget, forget: forget)}private func load() async {+ let revision = ExclusionsStore.shared.revision(receipts, filesOutside) = await Self.receipts(of: app, exclusions: ExclusionsStore.shared.exclusions)+ loadedUnder = revision}@concurrent