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.

Name the rule that holds every removal

Țugui Dragoșd1fff962cf47
diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swift
index 9deeef05..001d4043 100644
--- a/Peel/Model/RemovalHistoryStore.swift
+++ b/Peel/Model/RemovalHistoryStore.swift
@@ -275,15 +275,16 @@ final class RemovalHistoryStore {
/// What the Edit menu shows, and nil when there is nothing to undo.
var undoTitle: String? { undoable?.title }
- /// Whether a Put Back may run now: never while the exclusions are not known or History can't be read.
- var mayPutBack: Bool {
+ /// Whether anything may move to the Trash or back now: never while the exclusions are not known or History can't
+ /// be read.
+ var mayMove: Bool {
ExclusionsStore.shared.exclusions.isKnown && !isUnreadable
}
/// Puts the last batch back. Nothing happens while another Put Back runs or none may, and the batch stays
/// undoable: `restore` takes one at a time and would drop this one without a word.
func undoLastRemoval() async {
- guard let undoable, !isRestoring, mayPutBack else { return }
+ guard let undoable, !isRestoring, mayMove else { return }
self.undoable = nil
await restore(undoable.records, canUseHelper: canUseHelper)
}
@@ -334,7 +335,7 @@ final class RemovalHistoryStore {
func restore(_ records: [RemovalRecord], canUseHelper: Bool) async {
// One restore at a time, however often it is asked for: two rounds over the same records would each
// report the items the other put back as already there.
- guard !isRestoring, mayPutBack else { return }
+ guard !isRestoring, mayMove else { return }
isRestoring = true
defer { isRestoring = false }
let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)
diff --git a/Peel/Navigation/PeelCommands.swift b/Peel/Navigation/PeelCommands.swift
index 7a4f0c8c..41a4d3f1 100644
--- a/Peel/Navigation/PeelCommands.swift
+++ b/Peel/Navigation/PeelCommands.swift
@@ -80,7 +80,7 @@ struct PeelCommands: Commands {
}
.keyboardShortcut("z", modifiers: .command)
.disabled(
- history?.undoTitle == nil || history?.isRestoring == true || history?.mayPutBack != true
+ history?.undoTitle == nil || history?.isRestoring == true || history?.mayMove != true
|| sheetInFront.isShowing
)
Button("Redo") {}
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index d8fc73d2..c2ad6f3e 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -8,7 +8,6 @@ struct BackgroundItemDetailView: View {
@Environment(BackgroundItemLibrary.self) private var backgroundItems
@Environment(HelperModel.self) private var helper
@Environment(RemovalHistoryStore.self) private var history
- @Environment(ExclusionsStore.self) private var exclusions
@Environment(\.openSettings) private var openSettings
@State private var isConfirmingTrash = false
/// Reading this asks macOS, so it is read once per item and scan rather than on every evaluation of `body`.
@@ -368,8 +367,7 @@ struct BackgroundItemDetailView: View {
}
.buttonStyle(.borderedProminent)
.disabled(
- isBusy || item.removalRequiresPrivileges && !helper.canAct || !exclusions.exclusions.isKnown
- || history.isUnreadable
+ isBusy || item.removalRequiresPrivileges && !helper.canAct || !history.mayMove
)
}
}
diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swift
index 1a826591..e264e732 100644
--- a/Peel/Views/History/HistoryDetailView.swift
+++ b/Peel/Views/History/HistoryDetailView.swift
@@ -47,7 +47,7 @@ struct HistoryDetailView: View {
RestoreBar(
count: selectedCount,
isRestoring: history.isRestoring,
- isEnabled: selectedCount > 0 && !history.isRestoring && history.mayPutBack
+ isEnabled: selectedCount > 0 && !history.isRestoring && history.mayMove
) {
guard let standing else { return }
let selected = standing.selected(among: batch.records, in: history.selectedIDs)
diff --git a/Peel/Views/Plugins/PluginDetailView.swift b/Peel/Views/Plugins/PluginDetailView.swift
index bcdf9cea..0417c67e 100644
--- a/Peel/Views/Plugins/PluginDetailView.swift
+++ b/Peel/Views/Plugins/PluginDetailView.swift
@@ -6,7 +6,6 @@ struct PluginDetailView: View {
@Environment(PluginLibrary.self) private var plugins
@Environment(HelperModel.self) private var helper
@Environment(RemovalHistoryStore.self) private var history
- @Environment(ExclusionsStore.self) private var exclusions
@State private var isConfirmingRemoval = false
@Environment(RemovalOutcome.self) private var outcome
let plugin: Plugin
@@ -93,7 +92,7 @@ struct PluginDetailView: View {
.buttonStyle(.borderedProminent)
.disabled(
isLocked || plugin.refusal != nil || plugins.isRemoving || plugins.isScanning
- || !exclusions.exclusions.isKnown || history.isUnreadable
+ || !history.mayMove
)
}
}
diff --git a/Peel/Views/RemovalBar.swift b/Peel/Views/RemovalBar.swift
index e72f1172..e565a75a 100644
--- a/Peel/Views/RemovalBar.swift
+++ b/Peel/Views/RemovalBar.swift
@@ -2,7 +2,6 @@ import PeelCore
import SwiftUI
struct RemovalBar: View {
- @Environment(ExclusionsStore.self) private var exclusions
@Environment(RemovalHistoryStore.self) private var history
@Environment(SelectionCarrier.self) private var carrier
/// What the last removal moved while this bar was on screen, shown briefly in place of the selection.
@@ -133,7 +132,7 @@ struct RemovalBar: View {
var body: some View {
let reading = reading
- let isEnabled = reading.isEnabled && exclusions.exclusions.isKnown && !history.isUnreadable
+ let isEnabled = reading.isEnabled && history.mayMove
BusyShown(isBusy: moving?.isMoving == true) { isShowingMove in
BusyShown(isBusy: waitingToQuit != nil) { isShowingWait in
BusyShown(isBusy: isScanning) { isShowingScan in
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index 12e62e5c..5546041b 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -245,7 +245,7 @@ struct ResetSheet: View {
.buttonStyle(.borderedProminent)
.disabled(
!plan.hasAnythingToReset || plan.isResetting || plan.isAppRunning
- || !exclusions.exclusions.isKnown || history.isUnreadable
+ || !history.mayMove
)
}
.padding(.horizontal, 20)
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index a7dbe87f..babdccbc 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -435,7 +435,7 @@ private struct GeneralSettingsView: View {
.disabled(
selfUninstall.isRunning || !library.hasLoaded
|| (homebrew.isInstalled && homebrew.packages == nil)
- || !exclusions.exclusions.isKnown || history.isUnreadable
+ || !history.mayMove
)
}
if exclusions.exclusions.isUnreadable {
diff --git a/Peel/Views/Terminal/TerminalPage.swift b/Peel/Views/Terminal/TerminalPage.swift
index 24ec2aac..105e8b5e 100644
--- a/Peel/Views/Terminal/TerminalPage.swift
+++ b/Peel/Views/Terminal/TerminalPage.swift
@@ -277,7 +277,6 @@ private struct QuietLoginRow: View {
@Environment(TerminalLibrary.self) private var terminal
@Environment(RemovalHistoryStore.self) private var history
@Environment(RemovalOutcome.self) private var outcome
- @Environment(ExclusionsStore.self) private var exclusions
@State private var asked: Bool?
var body: some View {
@@ -292,7 +291,7 @@ private struct QuietLoginRow: View {
}
private var canMoveToTrash: Bool {
- exclusions.exclusions.isKnown && !history.isUnreadable
+ history.mayMove
}
private var isOn: Binding<Bool> {