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.

Ask Forget Receipt's question on the app's page itself

Țugui Dragoș3a6c3bd6a8e0
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index b746ac07..95496bff 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -72,6 +72,8 @@ struct AppDetailView: View {
.sheet(item: $upgradeOutput) { result in
HomebrewOutputView(result: result)
}
+ // On the page, never in the List: a question attached to rows the List hasn't built yet doesn't show.
+ .forgetReceiptDialog(for: $receiptToForget, forget: forgetReceipt)
// Keyed to what Homebrew knows: evidence that arrives after the page opened is a reason to look again.
.task(id: homebrew.evidenceRevision) {
// Arrowing down the list puts a page on screen for every row passed. The wait means a row left
@@ -190,10 +192,7 @@ struct AppDetailView: View {
reviewSection
AppRemovalOptions(plan: plan)
defaultsSection
- PackageReceiptSection(
- plan: plan, rescan: rescan,
- receiptToForget: $receiptToForget, isForgetting: $isForgettingReceipt
- )
+ PackageReceiptSection(plan: plan)
}
.dimmedWhileBusy(isAtWork)
.disabled(plan.isRemoving)
@@ -377,6 +376,21 @@ struct AppDetailView: View {
)
}
+ /// Forgets a receipt chosen from the More menu, then scans again, so the receipt leaves the page's lists.
+ private func forgetReceipt(
+ _ receipt: PackageReceipt, recording record: (TrashResult) async -> Void
+ ) async -> TrashResult {
+ isForgettingReceipt = true
+ defer { isForgettingReceipt = false }
+ let result = await QuitGuard.shared.run {
+ let result = await PackageActions.forget(receipt, exclusions: ExclusionsStore.shared.exclusions)
+ await record(result)
+ return result
+ }
+ await rescan()
+ return result
+ }
+
private func row(for leftover: Leftover) -> some View {
RemovalRow(
url: leftover.url,
diff --git a/Peel/Views/VendorNotes.swift b/Peel/Views/VendorNotes.swift
index a0665b24..f86bfffe 100644
--- a/Peel/Views/VendorNotes.swift
+++ b/Peel/Views/VendorNotes.swift
@@ -50,28 +50,20 @@ struct PackageReceiptSection: View {
private static let mostListed = 12
let plan: RemovalPlan
- /// Scans the page again, which reads the receipts again: a receipt forgotten here also leaves its lists.
- let rescan: () async -> Void
- /// Chosen from the page's More menu.
- @Binding var receiptToForget: PackageReceipt?
- @Binding var isForgetting: Bool
var body: some View {
- Group {
- if !plan.packageReceipts.isEmpty {
- Section {
- ForEach(plan.packageReceipts) { receipt in
- rows(for: receipt)
- }
- } header: {
- heading(
- "Installed by a Package",
- "macOS keeps a receipt of the files a package installed. The ones outside the app are listed here only to show them: other software may rely on them. If Peel also found one of them for this app, it appears in the lists above as well, and may be selected there. Forgetting a receipt, from the page’s More menu, moves it to the Trash: macOS stops counting the package as installed, and the files stay where they are."
- )
+ if !plan.packageReceipts.isEmpty {
+ Section {
+ ForEach(plan.packageReceipts) { receipt in
+ rows(for: receipt)
}
+ } header: {
+ heading(
+ "Installed by a Package",
+ "macOS keeps a receipt of the files a package installed. The ones outside the app are listed here only to show them: other software may rely on them. If Peel also found one of them for this app, it appears in the lists above as well, and may be selected there. Forgetting a receipt, from the page’s More menu, moves it to the Trash: macOS stops counting the package as installed, and the files stay where they are."
+ )
}
}
- .forgetReceiptDialog(for: $receiptToForget, forget: forget)
}
@ViewBuilder
@@ -116,16 +108,4 @@ struct PackageReceiptSection: View {
}
.padding(.vertical, 4)
}
-
- private func forget(_ receipt: PackageReceipt, recording record: (TrashResult) async -> Void) async -> TrashResult {
- isForgetting = true
- defer { isForgetting = false }
- let result = await QuitGuard.shared.run {
- let result = await PackageActions.forget(receipt, exclusions: ExclusionsStore.shared.exclusions)
- await record(result)
- return result
- }
- await rescan()
- return result
- }
}