mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-05 09:24:49 +01:00
Update for Big Sur & SwiftUI 2 (#128)
This commit is contained in:
@@ -11,8 +11,11 @@ public class Updater: ObservableObject, UpdaterProtocol {
|
||||
|
||||
@Published public var update: Release?
|
||||
|
||||
public init() {
|
||||
checkForUpdates()
|
||||
public init(checkOnLaunch: Bool) {
|
||||
if checkOnLaunch {
|
||||
// Don't do a launch check if the user hasn't seen the setup prompt explaining updater yet.
|
||||
checkForUpdates()
|
||||
}
|
||||
let timer = Timer.scheduledTimer(withTimeInterval: 60*60*24, repeats: true) { _ in
|
||||
self.checkForUpdates()
|
||||
}
|
||||
@@ -41,6 +44,7 @@ extension Updater {
|
||||
|
||||
func evaluate(release: Release) {
|
||||
guard !userIgnored(release: release) else { return }
|
||||
guard !release.prerelease else { return }
|
||||
let latestVersion = semVer(from: release.name)
|
||||
let currentVersion = semVer(from: Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String)
|
||||
for (latest, current) in zip(latestVersion, currentVersion) {
|
||||
@@ -82,22 +86,31 @@ extension Updater {
|
||||
public struct Release: Codable {
|
||||
|
||||
public let name: String
|
||||
public let prerelease: Bool
|
||||
public let html_url: URL
|
||||
public let body: String
|
||||
|
||||
public init(name: String, html_url: URL, body: String) {
|
||||
public init(name: String, prerelease: Bool, html_url: URL, body: String) {
|
||||
self.name = name
|
||||
self.prerelease = prerelease
|
||||
self.html_url = html_url
|
||||
self.body = body
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Release: Identifiable {
|
||||
|
||||
public var id: String {
|
||||
html_url.absoluteString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Release {
|
||||
|
||||
public var critical: Bool {
|
||||
return body.contains(Constants.securityContent)
|
||||
body.contains(Constants.securityContent)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user