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.

Unreadable exclusions lead Home and open Settings at Exclusions

Țugui Dragoș0329414a726c
diff --git a/Peel/Views/Home/HomePermissionsView.swift b/Peel/Views/Home/HomePermissionsView.swift
index 06ddb4a8..ed8b6c2c 100644
--- a/Peel/Views/Home/HomePermissionsView.swift
+++ b/Peel/Views/Home/HomePermissionsView.swift
@@ -7,7 +7,6 @@ struct HomePermissionsContent: View {
@Environment(HelperModel.self) private var helper
@Environment(ExclusionsStore.self) private var exclusions
@Environment(\.openSettings) private var openSettings
- @AppStorage(SettingsKey.pane) private var settingsPane = SettingsPane.general.rawValue
@State private var pointingAt: HomeModel.Permission?
static let markSize: CGFloat = 36
@@ -145,8 +144,7 @@ struct HomePermissionsContent: View {
if permission.isInSystemSettings {
reveal(permission)
} else {
- settingsPane = SettingsPane.general.rawValue
- openSettings()
+ SettingsPane.general.open(with: openSettings)
}
}
@@ -213,9 +211,19 @@ struct HomePermissionsContent: View {
.accessibilityHidden(true)
}
+ /// Unreadable exclusions come first: until they are read, nothing moves at all.
@ViewBuilder
private var banner: some View {
- if home.needsAttention {
+ if exclusions.exclusions.isUnreadable {
+ Notice(
+ title: Text("Peel couldn’t read your exclusions"),
+ detail: Text("Peel removes nothing and puts nothing back until you start the list over in Settings."),
+ isAlbum: true
+ ) {
+ Button("Open Peel Settings") { SettingsPane.exclusions.open(with: openSettings) }
+ .buttonStyle(.sticker(fill: Album.redFill, size: 11.5))
+ }
+ } else if home.needsAttention {
let missing = home.missingRequired.map { String(localized: $0.title) }.formatted(.list(type: .and))
Notice(
title: Text("Peel can’t see or remove everything yet"),
@@ -227,17 +235,6 @@ struct HomePermissionsContent: View {
.buttonStyle(.sticker(fill: Album.redFill, size: 11.5))
}
}
- } else if exclusions.exclusions.isUnreadable {
- Notice(
- title: Text("Peel couldn’t read your exclusions"),
- detail: Text("Peel removes nothing and puts nothing back until you start the list over in Settings."),
- isAlbum: true
- ) {
- SettingsLink {
- Text("Open Peel Settings")
- }
- .buttonStyle(.sticker(fill: Album.redFill, size: 11.5))
- }
} 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".
diff --git a/Peel/Views/RemovalsHeldBanner.swift b/Peel/Views/RemovalsHeldBanner.swift
index c289ddaf..05fcedaf 100644
--- a/Peel/Views/RemovalsHeldBanner.swift
+++ b/Peel/Views/RemovalsHeldBanner.swift
@@ -6,6 +6,7 @@ import SwiftUI
struct RemovalsHeldBanner: View {
@Environment(ExclusionsStore.self) private var exclusions
@Environment(RemovalHistoryStore.self) private var history
+ @Environment(\.openSettings) private var openSettings
/// On History's own page, whose list says it with Start Over beside it, History is left unsaid here.
var isOnHistoryPage = false
@@ -15,9 +16,7 @@ struct RemovalsHeldBanner: View {
title: Text("Peel couldn’t read your exclusions"),
detail: Text("Peel removes nothing and puts nothing back until you start the list over in Settings.")
) {
- SettingsLink {
- Text("Open Peel Settings")
- }
+ Button("Open Peel Settings") { SettingsPane.exclusions.open(with: openSettings) }
}
.padding(.vertical, 6)
.listRowSeparator(.hidden)
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index cfc65b3f..165c6184 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -11,6 +11,12 @@ enum SettingsPane: String {
case exclusions
case privacy
case helper
+
+ /// Opens Settings at this tab, where the action that sent the person there is.
+ func open(with openSettings: OpenSettingsAction) {
+ UserDefaults.standard.set(rawValue, forKey: SettingsKey.pane)
+ openSettings()
+ }
}
/// The Settings tabs, shared by the Settings window (Command-Comma) and the Settings page in Peel's sidebar.