* Show update-available banner automatically on launch Probe for updates immediately on launch via Sparkle's checkForUpdateInformation() so the sidebar surfaces a passive update indicator without waiting for the 24h scheduler. When Sparkle detects an available update in the background, the pill now shows "Update Available: X.Y.Z" with accent styling while the updater is idle. Clicking it triggers the full interactive update flow. Also fixes thread safety in delegate callbacks by dispatching @Published mutations to the main queue. Closes #1643 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add periodic background update probe every 15 minutes The launch-only probe wouldn't catch updates published while the app is already running. Add a repeating 15-minute timer that calls checkForUpdateInformation() so the sidebar banner appears within a reasonable window after a new version is published. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Change background update probe interval to 30 minutes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Change update check interval to 1 hour and migrate existing users Reduce Sparkle's scheduled check interval from 24h to 1h so update banners appear sooner. Migrate users stuck on the old 24h default by bumping the migration key to v2. Align background probe interval with the Sparkle check interval instead of hardcoding 30 minutes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
85 lines
2.6 KiB
Swift
85 lines
2.6 KiB
Swift
import SwiftUI
|
|
|
|
/// A badge view that displays the current state of an update operation.
|
|
struct UpdateBadge: View {
|
|
@ObservedObject var model: UpdateViewModel
|
|
|
|
var body: some View {
|
|
badgeContent
|
|
.accessibilityLabel(model.text)
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var badgeContent: some View {
|
|
if model.showsDetectedBackgroundUpdate {
|
|
if let iconName = model.iconName {
|
|
Image(systemName: iconName)
|
|
}
|
|
} else {
|
|
switch model.effectiveState {
|
|
case .downloading(let download):
|
|
if let expectedLength = download.expectedLength, expectedLength > 0 {
|
|
let progress = min(1, max(0, Double(download.progress) / Double(expectedLength)))
|
|
ProgressRingView(progress: progress)
|
|
} else {
|
|
Image(systemName: "arrow.down.circle")
|
|
}
|
|
|
|
case .extracting(let extracting):
|
|
ProgressRingView(progress: min(1, max(0, extracting.progress)))
|
|
|
|
case .checking:
|
|
BrowserStyleLoadingSpinner(size: 14, color: model.foregroundColor)
|
|
|
|
default:
|
|
if let iconName = model.iconName {
|
|
Image(systemName: iconName)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fileprivate struct ProgressRingView: View {
|
|
let progress: Double
|
|
let lineWidth: CGFloat = 2
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
Circle()
|
|
.stroke(Color.primary.opacity(0.2), lineWidth: lineWidth)
|
|
|
|
Circle()
|
|
.trim(from: 0, to: progress)
|
|
.stroke(Color.primary, style: StrokeStyle(lineWidth: lineWidth, lineCap: .round))
|
|
.rotationEffect(.degrees(-90))
|
|
.animation(.easeInOut(duration: 0.2), value: progress)
|
|
}
|
|
}
|
|
}
|
|
|
|
fileprivate struct BrowserStyleLoadingSpinner: View {
|
|
let size: CGFloat
|
|
let color: Color
|
|
|
|
var body: some View {
|
|
TimelineView(.animation) { context in
|
|
let t = context.date.timeIntervalSinceReferenceDate
|
|
let angle = (t.truncatingRemainder(dividingBy: 0.9) / 0.9) * 360.0
|
|
|
|
ZStack {
|
|
Circle()
|
|
.stroke(color.opacity(0.20), lineWidth: ringWidth)
|
|
Circle()
|
|
.trim(from: 0.0, to: 0.28)
|
|
.stroke(color, style: StrokeStyle(lineWidth: ringWidth, lineCap: .round))
|
|
.rotationEffect(.degrees(angle))
|
|
}
|
|
.frame(width: size, height: size)
|
|
}
|
|
}
|
|
|
|
private var ringWidth: CGFloat {
|
|
max(1.6, size * 0.14)
|
|
}
|
|
}
|