mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-23 05:57:07 +00:00
32 lines
813 B
Swift
32 lines
813 B
Swift
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"
|
|
let currentBuild = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
|
|
SettingsStore.set(key: Constants.previousVersionUserDefaultsKey, value: currentBuild)
|
|
justUpdated = lastBuild != currentBuild
|
|
}
|
|
}
|
|
|
|
extension JustUpdatedChecker {
|
|
|
|
enum Constants {
|
|
static let previousVersionUserDefaultsKey = "com.maxgoedjen.Secretive.lastBuild"
|
|
}
|
|
|
|
}
|