mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-11 20:36:39 +00:00
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.
This commit is contained in:

committed by
GitHub

parent
2bf9c777d7
commit
207eccffda
@@ -73,12 +73,10 @@ class UpdateDriver: NSObject, SPUUserDriver {
|
|||||||
|
|
||||||
func showUpdateNotFoundWithError(_ error: any Error,
|
func showUpdateNotFoundWithError(_ error: any Error,
|
||||||
acknowledgement: @escaping () -> Void) {
|
acknowledgement: @escaping () -> Void) {
|
||||||
viewModel.state = .notFound
|
viewModel.state = .notFound(.init(acknowledgement: acknowledgement))
|
||||||
|
|
||||||
if !hasUnobtrusiveTarget {
|
if !hasUnobtrusiveTarget {
|
||||||
standard.showUpdateNotFoundWithError(error, acknowledgement: acknowledgement)
|
standard.showUpdateNotFoundWithError(error, acknowledgement: acknowledgement)
|
||||||
} else {
|
|
||||||
acknowledgement()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,11 +23,12 @@ struct UpdatePill: View {
|
|||||||
.transition(.opacity.combined(with: .scale(scale: 0.95)))
|
.transition(.opacity.combined(with: .scale(scale: 0.95)))
|
||||||
.onChange(of: model.state) { newState in
|
.onChange(of: model.state) { newState in
|
||||||
resetTask?.cancel()
|
resetTask?.cancel()
|
||||||
if case .notFound = newState {
|
if case .notFound(let notFound) = newState {
|
||||||
resetTask = Task { [weak model] in
|
resetTask = Task { [weak model] in
|
||||||
try? await Task.sleep(for: .seconds(5))
|
try? await Task.sleep(for: .seconds(5))
|
||||||
guard !Task.isCancelled, case .notFound? = model?.state else { return }
|
guard !Task.isCancelled, case .notFound? = model?.state else { return }
|
||||||
model?.state = .idle
|
model?.state = .idle
|
||||||
|
notFound.acknowledgement()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resetTask = nil
|
resetTask = nil
|
||||||
@@ -40,8 +41,9 @@ struct UpdatePill: View {
|
|||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private var pillButton: some View {
|
private var pillButton: some View {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
if case .notFound = model.state {
|
if case .notFound(let notFound) = model.state {
|
||||||
model.state = .idle
|
model.state = .idle
|
||||||
|
notFound.acknowledgement()
|
||||||
} else {
|
} else {
|
||||||
showPopover.toggle()
|
showPopover.toggle()
|
||||||
}
|
}
|
||||||
|
@@ -41,8 +41,8 @@ struct UpdatePopoverView: View {
|
|||||||
case .installing:
|
case .installing:
|
||||||
InstallingView()
|
InstallingView()
|
||||||
|
|
||||||
case .notFound:
|
case .notFound(let notFound):
|
||||||
NotFoundView(dismiss: dismiss)
|
NotFoundView(notFound: notFound, dismiss: dismiss)
|
||||||
|
|
||||||
case .error(let error):
|
case .error(let error):
|
||||||
UpdateErrorView(error: error, dismiss: dismiss)
|
UpdateErrorView(error: error, dismiss: dismiss)
|
||||||
@@ -331,6 +331,7 @@ fileprivate struct InstallingView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileprivate struct NotFoundView: View {
|
fileprivate struct NotFoundView: View {
|
||||||
|
let notFound: UpdateState.NotFound
|
||||||
let dismiss: DismissAction
|
let dismiss: DismissAction
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -348,6 +349,7 @@ fileprivate struct NotFoundView: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button("OK") {
|
Button("OK") {
|
||||||
|
notFound.acknowledgement()
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
.keyboardShortcut(.defaultAction)
|
.keyboardShortcut(.defaultAction)
|
||||||
|
@@ -72,7 +72,9 @@ enum UpdateSimulator {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
|
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) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
|
||||||
viewModel.state = .idle
|
viewModel.state = .idle
|
||||||
|
@@ -135,7 +135,7 @@ enum UpdateState: Equatable {
|
|||||||
case permissionRequest(PermissionRequest)
|
case permissionRequest(PermissionRequest)
|
||||||
case checking(Checking)
|
case checking(Checking)
|
||||||
case updateAvailable(UpdateAvailable)
|
case updateAvailable(UpdateAvailable)
|
||||||
case notFound
|
case notFound(NotFound)
|
||||||
case error(Error)
|
case error(Error)
|
||||||
case downloading(Downloading)
|
case downloading(Downloading)
|
||||||
case extracting(Extracting)
|
case extracting(Extracting)
|
||||||
@@ -157,6 +157,8 @@ enum UpdateState: Equatable {
|
|||||||
downloading.cancel()
|
downloading.cancel()
|
||||||
case .readyToInstall(let ready):
|
case .readyToInstall(let ready):
|
||||||
ready.reply(.dismiss)
|
ready.reply(.dismiss)
|
||||||
|
case .notFound(let notFound):
|
||||||
|
notFound.acknowledgement()
|
||||||
case .error(let err):
|
case .error(let err):
|
||||||
err.dismiss()
|
err.dismiss()
|
||||||
default:
|
default:
|
||||||
@@ -191,6 +193,10 @@ enum UpdateState: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct NotFound {
|
||||||
|
let acknowledgement: () -> Void
|
||||||
|
}
|
||||||
|
|
||||||
struct PermissionRequest {
|
struct PermissionRequest {
|
||||||
let request: SPUUpdatePermissionRequest
|
let request: SPUUpdatePermissionRequest
|
||||||
let reply: @Sendable (SUUpdatePermissionResponse) -> Void
|
let reply: @Sendable (SUUpdatePermissionResponse) -> Void
|
||||||
|
Reference in New Issue
Block a user