2020-03-15 08:01:40 +00:00
|
|
|
import Foundation
|
2024-12-25 23:25:01 +00:00
|
|
|
import Synchronization
|
|
|
|
import Observation
|
2020-03-22 01:43:26 +00:00
|
|
|
import Brief
|
2020-03-15 08:01:40 +00:00
|
|
|
|
2024-12-25 23:25:01 +00:00
|
|
|
@Observable class PreviewUpdater: UpdaterProtocol {
|
|
|
|
|
|
|
|
var update: Release? {
|
|
|
|
_update.withLock { $0 }
|
|
|
|
}
|
2025-01-06 00:27:41 +00:00
|
|
|
let _update: Mutex<Release?> = .init(nil)
|
2020-03-15 08:01:40 +00:00
|
|
|
|
2021-12-31 22:59:12 +00:00
|
|
|
let testBuild = false
|
2020-03-15 08:01:40 +00:00
|
|
|
|
|
|
|
init(update: Update = .none) {
|
|
|
|
switch update {
|
|
|
|
case .none:
|
2024-12-25 23:25:01 +00:00
|
|
|
_update.withLock {
|
|
|
|
$0 = nil
|
|
|
|
}
|
2020-03-15 08:01:40 +00:00
|
|
|
case .advisory:
|
2024-12-25 23:25:01 +00:00
|
|
|
_update.withLock {
|
|
|
|
$0 = Release(name: "10.10.10", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Some regular update")
|
|
|
|
}
|
2020-03-15 08:01:40 +00:00
|
|
|
case .critical:
|
2024-12-25 23:25:01 +00:00
|
|
|
_update.withLock {
|
|
|
|
$0 = Release(name: "10.10.10", prerelease: false, html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
|
|
|
|
|
|
|
|
}
|
2020-03-15 08:01:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension PreviewUpdater {
|
|
|
|
|
|
|
|
enum Update {
|
|
|
|
case none, advisory, critical
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|