secretive/Sources/Secretive/Controllers/JustUpdatedChecker.swift

32 lines
813 B
Swift
Raw Normal View History

2020-04-04 22:16:31 +00:00
import Foundation
import Combine
import AppKit
protocol JustUpdatedCheckerProtocol: ObservableObject {
var justUpdated: Bool { get }
}
class JustUpdatedChecker: ObservableObject, JustUpdatedCheckerProtocol {
@Published var justUpdated: Bool = false
init() {
check()
}
func check() {
let lastBuild = SettingsStore.get(key: Constants.previousVersionUserDefaultsKey) ?? "None"
2020-04-04 22:16:31 +00:00
let currentBuild = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
SettingsStore.set(key: Constants.previousVersionUserDefaultsKey, value: currentBuild)
justUpdated = lastBuild != currentBuild
2020-04-04 22:16:31 +00:00
}
}
extension JustUpdatedChecker {
enum Constants {
static let previousVersionUserDefaultsKey = "com.maxgoedjen.Secretive.lastBuild"
}
}