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.

Closing the Reset sheet without a reset scans nothing

Țugui Dragoșa10a22ee3909
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index 297a2d86..10f3611c 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -19,6 +19,7 @@ struct AppDetailView: View {
@State private var upgradeOutput: HomebrewLibrary.CommandResult?
@Environment(\.notifications) private var notifications
@State private var isShowingReset = false
+ @State private var resetChangedFiles = false
/// The result of the last upgrade started from this page, shown under the buttons.
private enum Upgrade: Equatable {
@@ -58,8 +59,12 @@ struct AppDetailView: View {
Button("Quit \(plan.app.name)") { plan.quitApp() }
Button("Cancel", role: .cancel) {}
}
- .sheet(isPresented: $isShowingReset, onDismiss: { Task { await rescan() } }) {
- ResetSheet(app: plan.app)
+ .sheet(isPresented: $isShowingReset, onDismiss: {
+ guard resetChangedFiles else { return }
+ resetChangedFiles = false
+ Task { await rescan() }
+ }) {
+ ResetSheet(app: plan.app, changedFiles: $resetChangedFiles)
}
.sheet(item: $upgradeOutput) { result in
HomebrewOutputView(result: result)
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index 1cd87159..4d0d7939 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -10,14 +10,18 @@ struct ResetSheet: View {
@Environment(RemovalHistoryStore.self) private var history
@Environment(ExclusionsStore.self) private var exclusions
@State private var plan: ResetPlan
+ /// Set once the sheet has moved files to the Trash or put settings back, so the page behind it knows that what
+ /// it lists has changed.
+ @Binding var changedFiles: Bool
@State private var isConfirming = false
@State private var isPuttingBack = false
/// The result of Put Settings Back, or nil before it is pressed. A result is shown either way, so a success
/// doesn't look like a click that did nothing.
@State private var settingsWentBack: Bool?
- init(app: InstalledApp) {
+ init(app: InstalledApp, changedFiles: Binding<Bool>) {
_plan = State(initialValue: ResetPlan(app: app))
+ _changedFiles = changedFiles
}
var body: some View {
@@ -34,6 +38,9 @@ struct ResetSheet: View {
Button("Reset", role: .destructive) {
Task {
let result = await plan.performReset()
+ if !result.trashed.isEmpty {
+ changedFiles = true
+ }
await history.record(result, tool: .applications, source: plan.app.name, sizes: sizes)
}
}
@@ -245,6 +252,7 @@ struct ResetSheet: View {
Task {
isPuttingBack = true
settingsWentBack = await plan.putSettingsBack()
+ changedFiles = true
isPuttingBack = false
}
}