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 helper on Home as System Settings shows it

Țugui Dragoș6388cfe4fff7
diff --git a/Peel/Model/HomeModel.swift b/Peel/Model/HomeModel.swift
index 249cae1a..be3dbe2d 100644
--- a/Peel/Model/HomeModel.swift
+++ b/Peel/Model/HomeModel.swift
@@ -26,6 +26,17 @@ final class HomeModel {
}
}
+ /// What Home asks in System Settings of the permissions still waiting there. macOS lists the helper under Login
+ /// Items & Extensions as Peel itself, so it is never named by its title.
+ struct Waiting: Equatable {
+ let allowsPeel: Bool
+ let others: [Permission]
+ }
+
+ static func inSystemSettings(_ waiting: [Permission]) -> Waiting {
+ Waiting(allowsPeel: waiting.contains(.helper), others: waiting.filter { $0 != .helper })
+ }
+
var title: LocalizedStringResource {
switch self {
case .fullDiskAccess: "Full Disk Access"
diff --git a/Peel/Views/Home/HomePermissionsView.swift b/Peel/Views/Home/HomePermissionsView.swift
index a650ab9f..784fd09c 100644
--- a/Peel/Views/Home/HomePermissionsView.swift
+++ b/Peel/Views/Home/HomePermissionsView.swift
@@ -255,10 +255,16 @@ struct HomePermissionsContent: View {
} else if !home.waitingRequired.isEmpty, home.hasChecked {
// A required permission that is still pending is not set up. For example, a helper waiting for
// approval cannot move anything that needs an administrator, so Home must not say "You're all set".
- let waiting = home.waitingRequired.map { String(localized: $0.title) }.formatted(.list(type: .and))
+ let waiting = HomeModel.Permission.inSystemSettings(home.waitingRequired)
+ let others = waiting.others.map { String(localized: $0.title) }.formatted(.list(type: .and))
+ let sentences = [
+ waiting.allowsPeel
+ ? String(localized: "Allow Peel in System Settings under Login Items & Extensions.") : nil,
+ waiting.others.isEmpty ? nil : String(localized: "Check \(others) in System Settings."),
+ ]
Notice(
title: Text("Almost there"),
- detail: Text("Check \(waiting) in System Settings."),
+ detail: Text(verbatim: sentences.compactMap(\.self).joined(separator: "\n")),
kind: .note,
isAlbum: true
) {}
diff --git a/PeelTests/WaitingPermissionsTests.swift b/PeelTests/WaitingPermissionsTests.swift
new file mode 100644
index 00000000..350c0720
--- /dev/null
+++ b/PeelTests/WaitingPermissionsTests.swift
@@ -0,0 +1,14 @@
+@testable import Peel
+import Testing
+
+@MainActor
+struct WaitingPermissionsTests {
+ @Test func namesTheHelperAsSystemSettingsDoes() {
+ typealias Waiting = HomeModel.Permission.Waiting
+ let named = HomeModel.Permission.inSystemSettings
+
+ #expect(named([.helper]) == Waiting(allowsPeel: true, others: []))
+ #expect(named([.fullDiskAccess, .helper]) == Waiting(allowsPeel: true, others: [.fullDiskAccess]))
+ #expect(named([.fullDiskAccess]) == Waiting(allowsPeel: false, others: [.fullDiskAccess]))
+ }
+}