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() {
|
2024-02-29 18:55:20 +00:00
|
|
|
let lastBuild = SettingsStore.get(key: Constants.previousVersionUserDefaultsKey) ?? "None"
|
2020-04-04 22:16:31 +00:00
|
|
|
let currentBuild = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
|
2024-02-29 18:55:20 +00:00
|
|
|
SettingsStore.set(key: Constants.previousVersionUserDefaultsKey, value: currentBuild)
|
2020-11-13 06:55:52 +00:00
|
|
|
justUpdated = lastBuild != currentBuild
|
2020-04-04 22:16:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension JustUpdatedChecker {
|
|
|
|
|
|
|
|
enum Constants {
|
|
|
|
static let previousVersionUserDefaultsKey = "com.maxgoedjen.Secretive.lastBuild"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|