summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Hashimoto <m@mitchellh.com>2025-10-10 09:30:12 -0700
committerGitHub <noreply@github.com>2025-10-10 09:30:12 -0700
commit207eccffda019f11e87d2af7c0a98c9223b228b7 (patch)
tree105f786e35ee69e6ab2ce2497c988bcf32002f14
parent2bf9c777d769e08596c62c7064fd8af086d70229 (diff)
macos: Sparkle notFound acknowledgement should only be called on dismiss (#9126)
This was causing the "no update found" message to never really appear in the real world.
-rw-r--r--macos/Sources/Features/Update/UpdateDriver.swift4
-rw-r--r--macos/Sources/Features/Update/UpdatePill.swift6
-rw-r--r--macos/Sources/Features/Update/UpdatePopoverView.swift6
-rw-r--r--macos/Sources/Features/Update/UpdateSimulator.swift4
-rw-r--r--macos/Sources/Features/Update/UpdateViewModel.swift8
5 files changed, 19 insertions, 9 deletions
diff --git a/macos/Sources/Features/Update/UpdateDriver.swift b/macos/Sources/Features/Update/UpdateDriver.swift
index 9196d9ad9..81477ef67 100644
--- a/macos/Sources/Features/Update/UpdateDriver.swift
+++ b/macos/Sources/Features/Update/UpdateDriver.swift
@@ -73,12 +73,10 @@ class UpdateDriver: NSObject, SPUUserDriver {
func showUpdateNotFoundWithError(_ error: any Error,
acknowledgement: @escaping () -> Void) {
- viewModel.state = .notFound
+ viewModel.state = .notFound(.init(acknowledgement: acknowledgement))
if !hasUnobtrusiveTarget {
standard.showUpdateNotFoundWithError(error, acknowledgement: acknowledgement)
- } else {
- acknowledgement()
}
}
diff --git a/macos/Sources/Features/Update/UpdatePill.swift b/macos/Sources/Features/Update/UpdatePill.swift
index ff4af97dd..29d1669e1 100644
--- a/macos/Sources/Features/Update/UpdatePill.swift
+++ b/macos/Sources/Features/Update/UpdatePill.swift
@@ -23,11 +23,12 @@ struct UpdatePill: View {
.transition(.opacity.combined(with: .scale(scale: 0.95)))
.onChange(of: model.state) { newState in
resetTask?.cancel()
- if case .notFound = newState {
+ if case .notFound(let notFound) = newState {
resetTask = Task { [weak model] in
try? await Task.sleep(for: .seconds(5))
guard !Task.isCancelled, case .notFound? = model?.state else { return }
model?.state = .idle
+ notFound.acknowledgement()
}
} else {
resetTask = nil
@@ -40,8 +41,9 @@ struct UpdatePill: View {
@ViewBuilder
private var pillButton: some View {
Button(action: {
- if case .notFound = model.state {
+ if case .notFound(let notFound) = model.state {
model.state = .idle
+ notFound.acknowledgement()
} else {
showPopover.toggle()
}
diff --git a/macos/Sources/Features/Update/UpdatePopoverView.swift b/macos/Sources/Features/Update/UpdatePopoverView.swift
index 7634d27de..236649c21 100644
--- a/macos/Sources/Features/Update/UpdatePopoverView.swift
+++ b/macos/Sources/Features/Update/UpdatePopoverView.swift
@@ -41,8 +41,8 @@ struct UpdatePopoverView: View {
case .installing:
InstallingView()
- case .notFound:
- NotFoundView(dismiss: dismiss)
+ case .notFound(let notFound):
+ NotFoundView(notFound: notFound, dismiss: dismiss)
case .error(let error):
UpdateErrorView(error: error, dismiss: dismiss)
@@ -331,6 +331,7 @@ fileprivate struct InstallingView: View {
}
fileprivate struct NotFoundView: View {
+ let notFound: UpdateState.NotFound
let dismiss: DismissAction
var body: some View {
@@ -348,6 +349,7 @@ fileprivate struct NotFoundView: View {
HStack {
Spacer()
Button("OK") {
+ notFound.acknowledgement()
dismiss()
}
.keyboardShortcut(.defaultAction)
diff --git a/macos/Sources/Features/Update/UpdateSimulator.swift b/macos/Sources/Features/Update/UpdateSimulator.swift
index 96fab4835..f40bbee1b 100644
--- a/macos/Sources/Features/Update/UpdateSimulator.swift
+++ b/macos/Sources/Features/Update/UpdateSimulator.swift
@@ -72,7 +72,9 @@ enum UpdateSimulator {
}))
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
- viewModel.state = .notFound
+ viewModel.state = .notFound(.init(acknowledgement: {
+ // Acknowledgement called when dismissed
+ }))
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
viewModel.state = .idle
diff --git a/macos/Sources/Features/Update/UpdateViewModel.swift b/macos/Sources/Features/Update/UpdateViewModel.swift
index 6341b3b42..b0c6650c4 100644
--- a/macos/Sources/Features/Update/UpdateViewModel.swift
+++ b/macos/Sources/Features/Update/UpdateViewModel.swift
@@ -135,7 +135,7 @@ enum UpdateState: Equatable {
case permissionRequest(PermissionRequest)
case checking(Checking)
case updateAvailable(UpdateAvailable)
- case notFound
+ case notFound(NotFound)
case error(Error)
case downloading(Downloading)
case extracting(Extracting)
@@ -157,6 +157,8 @@ enum UpdateState: Equatable {
downloading.cancel()
case .readyToInstall(let ready):
ready.reply(.dismiss)
+ case .notFound(let notFound):
+ notFound.acknowledgement()
case .error(let err):
err.dismiss()
default:
@@ -191,6 +193,10 @@ enum UpdateState: Equatable {
}
}
+ struct NotFound {
+ let acknowledgement: () -> Void
+ }
+
struct PermissionRequest {
let request: SPUUpdatePermissionRequest
let reply: @Sendable (SUUpdatePermissionResponse) -> Void