secretive/Sources/Secretive/Controllers/JustUpdatedChecker.swift
Paul Heidekrüger 52f3fea9a8 Revert "Use keychain instead of UserDefaults in JustUpdatedChecker.swift"
This reverts commit ae8a21a1bf7f9e2d04fcb83c4543995db0111325.
2024-09-29 16:12:22 -07:00

35 lines
845 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 = 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"
}
}