mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-08-27 15:40:57 +00:00
34 lines
807 B
Swift
34 lines
807 B
Swift
import Foundation
|
|
import AppKit
|
|
|
|
protocol JustUpdatedCheckerProtocol: Observable {
|
|
var justUpdated: Bool { get }
|
|
}
|
|
|
|
@Observable class JustUpdatedChecker: JustUpdatedCheckerProtocol {
|
|
|
|
var justUpdated: Bool = false
|
|
|
|
init() {
|
|
check()
|
|
}
|
|
|
|
func check() {
|
|
let lastBuild = UserDefaults.standard.object(forKey: Constants.previousVersionUserDefaultsKey) as? String ?? "None"
|
|
let currentBuild = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
|
|
UserDefaults.standard.set(currentBuild, forKey: Constants.previousVersionUserDefaultsKey)
|
|
justUpdated = lastBuild != currentBuild
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
extension JustUpdatedChecker {
|
|
|
|
enum Constants {
|
|
static let previousVersionUserDefaultsKey = "com.maxgoedjen.Secretive.lastBuild"
|
|
}
|
|
|
|
}
|