secretive/Sources/Secretive/Preview Content/PreviewUpdater.swift
2025-01-05 16:25:16 -08:00

43 lines
974 B
Swift

import Foundation
import Synchronization
import Observation
import Brief
import Backports
@Observable class PreviewUpdater: UpdaterProtocol {
var update: Release? {
_update.withLock { $0 }
}
let _update: _Mutex<Release?> = .init(nil)
let testBuild = false
init(update: Update = .none) {
switch update {
case .none:
_update.withLock {
$0 = nil
}
case .advisory:
_update.withLock {
$0 = Release(name: "10.10.10", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Some regular update")
}
case .critical:
_update.withLock {
$0 = Release(name: "10.10.10", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
}
}
}
}
extension PreviewUpdater {
enum Update {
case none, advisory, critical
}
}