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.

Ask which tools the sidebar leaves out in one way everywhere

Țugui Dragoș6be835d771fa
diff --git a/Peel/Navigation/Tool.swift b/Peel/Navigation/Tool.swift
index ae6eef3b..0b23d34e 100644
--- a/Peel/Navigation/Tool.swift
+++ b/Peel/Navigation/Tool.swift
@@ -125,6 +125,12 @@ extension Tool {
return tool.canBeHidden && !choices.shows(tool.rawValue, byDefault: byDefault)
})
}
+
+ /// `hidden(by:homebrewIsInstalled:)` as the sidebar, Settings, and the menu bar panel all ask it, so they agree:
+ /// Homebrew's page shows while Homebrew is on this Mac, even when Peel won't run it, so the page can say why.
+ static func hidden(by choices: SidebarChoices, homebrew: HomebrewLibrary) -> Set<Tool> {
+ hidden(by: choices, homebrewIsInstalled: homebrew.isOnThisMac)
+ }
}
extension Tool.Group {
diff --git a/Peel/Navigation/ToolSidebar.swift b/Peel/Navigation/ToolSidebar.swift
index b8834b62..07977833 100644
--- a/Peel/Navigation/ToolSidebar.swift
+++ b/Peel/Navigation/ToolSidebar.swift
@@ -178,7 +178,7 @@ struct ToolSidebar: View {
}
private func shown(_ tools: [Tool]) -> [Tool] {
- let hidden = Tool.hidden(by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isInstalled)
+ let hidden = Tool.hidden(by: SidebarChoices(stored: sidebarTools), homebrew: homebrew)
return tools.filter { !hidden.contains($0) }
}
diff --git a/Peel/Views/MenuBarFound.swift b/Peel/Views/MenuBarFound.swift
index 3f68cfc8..44f83275 100644
--- a/Peel/Views/MenuBarFound.swift
+++ b/Peel/Views/MenuBarFound.swift
@@ -44,9 +44,7 @@ struct MenuBarFound: View {
}
private var lines: [Line] {
- let hidden = Tool.hidden(
- by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isOnThisMac
- )
+ let hidden = Tool.hidden(by: SidebarChoices(stored: sidebarTools), homebrew: homebrew)
return store.findings.compactMap { tool, finding in
let looked = Looked(count: finding.count, size: finding.size)
guard
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index 9be57e5c..adc8a730 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -614,9 +614,7 @@ extension GeneralSettingsView {
extension GeneralSettingsView {
private var sidebarToolsSummary: String {
- let hidden = Tool.hidden(
- by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isOnThisMac
- )
+ let hidden = Tool.hidden(by: SidebarChoices(stored: sidebarTools), homebrew: homebrew)
let left = Tool.Group.allCases.flatMap(\.tools).filter(hidden.contains).map { String(localized: $0.title) }
guard !left.isEmpty else { return String(localized: "Every tool is in the sidebar.") }
return String(localized: "Left out: \(left.formatted(.list(type: .and))).")
@@ -638,9 +636,7 @@ extension GeneralSettingsView {
fileprivate func showsInSidebar(_ tool: Tool) -> Binding<Bool> {
Binding(
get: {
- !Tool.hidden(
- by: SidebarChoices(stored: sidebarTools), homebrewIsInstalled: homebrew.isOnThisMac
- ).contains(tool)
+ !Tool.hidden(by: SidebarChoices(stored: sidebarTools), homebrew: homebrew).contains(tool)
},
set: { shows in
var choices = SidebarChoices(stored: sidebarTools)