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.

Say on Home and in Settings what a change of the helper is doing

Țugui Dragoș6b63b7d9b508
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index a54cea30..26f611b6 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -57816,6 +57816,112 @@
}
}
},
+ "Installing…" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Instalace…"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Installieren …"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Instalando…"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Installation…"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Installo…"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "インストール中…"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "설치 중…"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Installeren…"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Instaluję…"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Instalando…"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Instalare…"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Установка…"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Installerar…"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yükleniyor…"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Інсталювання…"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "正在安装…"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "安裝中⋯"
+ }
+ }
+ }
+ },
"Instead of the accent picker, holding a letter types it again and again." : {
"localizations" : {
"cs" : {
@@ -123902,6 +124008,112 @@
}
}
},
+ "Repairing…" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Oprava…"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Reparieren …"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Reparando…"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Réparation…"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Riparo…"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "修復中…"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "복구 중…"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Herstellen…"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Naprawiam…"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Reparando…"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Reparare…"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Исправление…"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Reparerar…"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Onarılıyor…"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Лагодження…"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "正在修复…"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "修復中⋯"
+ }
+ }
+ }
+ },
"Replaced" : {
"localizations" : {
"cs" : {
@@ -166306,6 +166518,112 @@
}
}
},
+ "Uninstalling…" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Odinstalace…"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Deinstallieren …"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Desinstalando…"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Désinstallation…"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Disinstallo…"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "アンインストール中…"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "제거 중…"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Deïnstalleren…"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Odinstalowuję…"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Desinstalando…"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dezinstalare…"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Удаление…"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Avinstallerar…"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Kaldırılıyor…"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Деінсталювання…"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "正在卸载…"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "解除安裝中⋯"
+ }
+ }
+ }
+ },
"Unity Asset Store" : {
"comment" : "A product's name, never translated.",
"shouldTranslate" : false
diff --git a/Peel/Model/HelperModel.swift b/Peel/Model/HelperModel.swift
index 864d82d9..af2c5139 100644
--- a/Peel/Model/HelperModel.swift
+++ b/Peel/Model/HelperModel.swift
@@ -4,17 +4,22 @@ import PeelCore
@Observable
final class HelperModel {
+ enum Action { case install, repair, uninstall }
+
private(set) var status = PrivilegedHelper.status
- private(set) var isChanging = false
+ private(set) var changing: Action?
private(set) var isResponding: Bool?
var failure: Failure?
struct Failure {
- enum Action { case install, repair, uninstall }
let action: Action
let reason: String
}
+ var isChanging: Bool {
+ changing != nil
+ }
+
/// Whether the helper can move items: it is registered, this account may use it, and it has not failed to
/// answer. Otherwise the items that need it stay locked.
var canAct: Bool {
@@ -60,7 +65,7 @@ final class HelperModel {
/// throws an error. Neither is reported as a failure, since the status says what happened.
func install() async {
guard !isChanging else { return }
- let error = await change { try await PrivilegedHelper.register() }
+ let error = await change(.install) { try await PrivilegedHelper.register() }
if let error, status != .requiresApproval, status != .enabled {
failure = Failure(action: .install, reason: error.localizedDescription)
}
@@ -71,7 +76,7 @@ final class HelperModel {
func repair() async {
guard !isChanging else { return }
- if let error = await change({ try await PrivilegedHelper.repair() }) {
+ if let error = await change(.repair, { try await PrivilegedHelper.repair() }) {
failure = Failure(action: .repair, reason: error.localizedDescription)
}
if status == .requiresApproval {
@@ -81,16 +86,16 @@ final class HelperModel {
func uninstall() async {
guard !isChanging else { return }
- if let error = await change({ try await PrivilegedHelper.unregister() }) {
+ if let error = await change(.uninstall, { try await PrivilegedHelper.unregister() }) {
failure = Failure(action: .uninstall, reason: error.localizedDescription)
}
}
/// Runs a change of the helper's registration and answers the error it threw, if any. Nothing about the helper
/// shows while it runs, and what it leaves shows only through the check that follows it.
- private func change(_ body: () async throws -> Void) async -> (any Error)? {
- isChanging = true
- defer { isChanging = false }
+ private func change(_ action: Action, _ body: () async throws -> Void) async -> (any Error)? {
+ changing = action
+ defer { changing = nil }
checks.changeStarts()
var error: (any Error)?
do {
diff --git a/Peel/Views/Home/HomePermissionsView.swift b/Peel/Views/Home/HomePermissionsView.swift
index 99a194a0..c054a8fb 100644
--- a/Peel/Views/Home/HomePermissionsView.swift
+++ b/Peel/Views/Home/HomePermissionsView.swift
@@ -40,6 +40,7 @@ struct HomePermissionsContent: View {
.frame(maxWidth: 720, alignment: .leading)
.frame(maxWidth: .infinity, alignment: .leading)
.motion(value: home.states)
+ .motion(value: helper.changing)
}
/// A card for one section, laid out as a grid so the states line up in one column and the actions in
@@ -75,6 +76,7 @@ struct HomePermissionsContent: View {
private func row(_ permission: HomeModel.Permission) -> some View {
let state = home.state(of: permission)
+ let changing = permission == .helper ? helper.changing : nil
return GridRow {
// The state sits under the name, as in System Settings, and a long name wraps instead of
// shrinking. A column of its own for the state would leave a translated name almost no room.
@@ -102,9 +104,9 @@ struct HomePermissionsContent: View {
isAlbum: true
)
}
- Text(home.status(of: permission))
+ Text(changing?.progress ?? home.status(of: permission))
.font(.system(size: 11.5, weight: .medium))
- .foregroundStyle(state.isMissing ? Album.red : .secondary)
+ .foregroundStyle(state.isMissing && changing == nil ? Album.red : .secondary)
.fixedSize(horizontal: false, vertical: true)
}
}
@@ -176,6 +178,7 @@ struct HomePermissionsContent: View {
.keepsWordsWhole(String(localized: action))
}
.buttonStyle(state.isMissing ? .sticker(fill: Album.redFill, size: 11.5) : .stickerQuiet)
+ .disabled(permission == .helper && helper.isChanging)
.accessibilityLabel(Text("\(String(localized: action)): \(String(localized: permission.title))", comment: "What VoiceOver reads for a button. The first %@ is the action, such as Install. The second is what it acts on, such as Helper."))
}
} else {
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index a2270c57..d6699046 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -115,6 +115,16 @@ extension SearchLocation.Kind {
}
}
+extension HelperModel.Action {
+ var progress: LocalizedStringResource {
+ switch self {
+ case .install: "Installing…"
+ case .repair: "Repairing…"
+ case .uninstall: "Uninstalling…"
+ }
+ }
+}
+
extension UninstallsItself {
var warning: Text {
switch uninstaller {
diff --git a/Peel/Views/Settings/SettingsView.swift b/Peel/Views/Settings/SettingsView.swift
index a705eea2..354c9907 100644
--- a/Peel/Views/Settings/SettingsView.swift
+++ b/Peel/Views/Settings/SettingsView.swift
@@ -702,7 +702,9 @@ private struct HelperSettingsView: View {
@ViewBuilder
private var statusBadge: some View {
- if !helper.hasChecked {
+ if let changing = helper.changing {
+ state(changing.progress, "hourglass", .secondary)
+ } else if !helper.hasChecked {
state("Checking…", "hourglass", .secondary)
} else {
switch helper.standing {