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
Put back as peel restore does, and never while removals are held
Țugui Dragoșfca857eca12f
diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swiftindex d0d9881e..9deeef05 100644--- a/Peel/Model/RemovalHistoryStore.swift+++ b/Peel/Model/RemovalHistoryStore.swift@@ -275,10 +275,15 @@ final class RemovalHistoryStore {/// What the Edit menu shows, and nil when there is nothing to undo.var undoTitle: String? { undoable?.title }- /// Puts the last batch back. Nothing happens while another Put Back runs, and the batch stays undoable: `restore`- /// takes one at a time and would drop this one without a word.+ /// Whether a Put Back may run now: never while the exclusions are not known or History can't be read.+ var mayPutBack: 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 else { return }+ guard let undoable, !isRestoring, mayPutBack else { return }self.undoable = nilawait restore(undoable.records, canUseHelper: canUseHelper)}@@ -329,10 +334,10 @@ 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 else { return }+ guard !isRestoring, mayPutBack else { return }isRestoring = truedefer { isRestoring = false }- let service = TrashService()+ let service = TrashService(exclusions: ExclusionsStore.shared.exclusions)await QuitGuard.shared.run {var restored: Set<UUID> = []var problems: [RemovalRecord.ID: RestoreFailure] = [:]diff --git a/Peel/Navigation/PeelCommands.swift b/Peel/Navigation/PeelCommands.swiftindex 77071a93..7a4f0c8c 100644--- a/Peel/Navigation/PeelCommands.swift+++ b/Peel/Navigation/PeelCommands.swift@@ -79,7 +79,10 @@ struct PeelCommands: Commands {}}.keyboardShortcut("z", modifiers: .command)- .disabled(history?.undoTitle == nil || history?.isRestoring == true || sheetInFront.isShowing)+ .disabled(+ history?.undoTitle == nil || history?.isRestoring == true || history?.mayPutBack != true+ || sheetInFront.isShowing+ )Button("Redo") {}.keyboardShortcut("z", modifiers: [.command, .shift]).disabled(true)diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swiftindex db70e126..1a826591 100644--- a/Peel/Views/History/HistoryDetailView.swift+++ b/Peel/Views/History/HistoryDetailView.swift@@ -5,7 +5,6 @@ import SwiftUIstruct HistoryDetailView: View {@Environment(RemovalHistoryStore.self) private var history@Environment(HelperModel.self) private var helper- @Environment(ExclusionsStore.self) private var exclusions@Environment(\.controlActiveState) private var controlActiveState@Environment(\.openSettings) private var openSettings/// Nil until the disk has answered. An empty value would show every record as gone from the Trash for a@@ -48,8 +47,7 @@ struct HistoryDetailView: View {RestoreBar(count: selectedCount,isRestoring: history.isRestoring,- isEnabled: selectedCount > 0 && !history.isRestoring && exclusions.exclusions.isKnown- && !history.isUnreadable+ isEnabled: selectedCount > 0 && !history.isRestoring && history.mayPutBack) {guard let standing else { return }let selected = standing.selected(among: batch.records, in: history.selectedIDs)