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.

Keep waiting for an app to quit before its upgrade while the page scrolls

Țugui Dragoș2a5b586a260c
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index 95496bff..838bb069 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -9,6 +9,7 @@ struct AppDetailView: View {
@Environment(HomebrewLibrary.self) private var homebrew
@State private var plan: RemovalPlan
@State private var quitting = QuitBeforeRemoving()
+ @State private var quittingToUpgrade = QuitBeforeRemoving()
@Environment(RemovalOutcome.self) private var outcome
@State private var isRescanning = false
@State private var progress = MoveProgress()
@@ -62,6 +63,7 @@ struct AppDetailView: View {
}
.forceQuitOffer(quitting)
.onDisappear { quitting.giveUp() }
+ .quitBeforeHomebrew(quittingToUpgrade, upgrading: true)
.sheet(isPresented: $isShowingReset, onDismiss: {
guard resetChangedFiles else { return }
resetChangedFiles = false
@@ -112,7 +114,8 @@ struct AppDetailView: View {
upgradeOutput: $upgradeOutput,
receiptToForget: $receiptToForget,
isForgettingReceipt: isForgettingReceipt,
- isRemoving: plan.isRemoving || quitting.isWaiting
+ isRemoving: plan.isRemoving || quitting.isWaiting,
+ quittingToUpgrade: quittingToUpgrade
)
.listRowSeparator(.hidden)
diff --git a/Peel/Views/AppPageHeader.swift b/Peel/Views/AppPageHeader.swift
index 8fda3bfd..10359a58 100644
--- a/Peel/Views/AppPageHeader.swift
+++ b/Peel/Views/AppPageHeader.swift
@@ -19,7 +19,9 @@ struct AppPageHeader: View {
let isForgettingReceipt: Bool
/// True while the page removes the app or waits for it to quit first, when nothing else is started from here.
let isRemoving: Bool
- @State private var quitting = QuitBeforeRemoving()
+ /// Asks the app to quit before Homebrew upgrades it. The page owns it and shows its questions, since a List
+ /// takes this header away when it is scrolled out of view, and that would end the wait.
+ let quittingToUpgrade: QuitBeforeRemoving
var body: some View {
AppHeader(
@@ -34,7 +36,6 @@ struct AppPageHeader: View {
) {
appActions
}
- .quitBeforeHomebrew(quitting, upgrading: true)
}
/// The version an update would bring. Nil when there is no update, or when the user muted this app or
@@ -214,7 +215,7 @@ struct AppPageHeader: View {
}
}
.buttonStyle(.borderedProminent)
- .disabled(homebrew.runningCommand != nil || quitting.isWaiting)
+ .disabled(homebrew.runningCommand != nil || quittingToUpgrade.isWaiting)
case .developer, .automatic:
Button("Open \(plan.app.name)", systemImage: "arrow.up.forward.app") {
NSWorkspace.shared.open(plan.app.url)
@@ -231,7 +232,7 @@ struct AppPageHeader: View {
private func upgradeWithHomebrew() {
guard let cask = library.cask(for: plan.app) else { return }
let quit = QuitBeforeHomebrew([cask], library: library)
- quitting.check(quit.processes) {
+ quittingToUpgrade.check(quit.processes) {
Task {
await upgrade(cask)
quit.reopen()