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.

Show the Watch the Trash warning only when watching failed

Țugui Dragoșc33f2bfb8192
diff --git a/Peel/Model/TrashMonitor.swift b/Peel/Model/TrashMonitor.swift
index 206cc72d..2ea84798 100644
--- a/Peel/Model/TrashMonitor.swift
+++ b/Peel/Model/TrashMonitor.swift
@@ -8,9 +8,12 @@ import PeelCore
@Observable
final class TrashMonitor {
enum Status {
+ /// Not asked to watch, or stopped.
case off
case watching
case needsFullDiskAccess
+ /// Asked to watch, and the Trash could not be watched.
+ case unavailable
}
/// The home Trash's watch, the one macOS keeps behind Full Disk Access.
@@ -47,13 +50,13 @@ final class TrashMonitor {
return
case .unavailable:
OwnTrashMoves.shared.whenSettled(nil)
- status = .off
+ status = .unavailable
return
}
watch.onRestart = { [weak self] result in
guard result != .watching else { return }
self?.stop()
- self?.status = result == .refused ? .needsFullDiskAccess : .off
+ self?.status = result == .refused ? .needsFullDiskAccess : .unavailable
}
startVolumes()
}
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index f7938ed2..d1a6ed01 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -288,7 +288,7 @@ private struct GeneralSettingsView: View {
home.openFullDiskAccessSettings()
}
}
- } else if watchesTrash, trashMonitor.status == .off {
+ } else if watchesTrash, trashMonitor.status == .unavailable {
WarningLabel(title: Text("Peel isn’t watching the Trash right now. It tries again each time you come back to Peel."))
}
toggle("Warn when the disk is almost full", isOn: $warnsWhenDiskIsNearlyFull,