mirror of
https://github.com/lil-org/wallet.git
synced 2024-12-29 07:22:04 +03:00
keep didReceiveShouldUpdateAppNotification in defaults
This commit is contained in:
parent
6c843c2c64
commit
1527d1fe8c
@ -24,4 +24,13 @@ struct Defaults {
|
||||
}
|
||||
}
|
||||
|
||||
static var didReceiveShouldUpdateAppNotification: Bool {
|
||||
get {
|
||||
return userDefaults.bool(forKey: "didReceiveShouldUpdateAppNotification")
|
||||
}
|
||||
set {
|
||||
userDefaults.set(newValue, forKey: "didReceiveShouldUpdateAppNotification")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import Foundation
|
||||
|
||||
class ConfigurationService {
|
||||
|
||||
var shouldUpdateApp = false // TODO: implement with defaults
|
||||
var shouldUpdateApp = Defaults.didReceiveShouldUpdateAppNotification
|
||||
|
||||
private struct ConfigurationResponse: Codable {
|
||||
let shouldUpdateApp: Bool
|
||||
@ -17,7 +17,9 @@ class ConfigurationService {
|
||||
private let urlSession = URLSession(configuration: .ephemeral)
|
||||
|
||||
func check() {
|
||||
getConfiguration()
|
||||
if !shouldUpdateApp {
|
||||
getConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
private func getConfiguration() {
|
||||
@ -25,7 +27,10 @@ class ConfigurationService {
|
||||
let dataTask = urlSession.dataTask(with: url) { [weak self] (data, _, _) in
|
||||
if let data = data, let configuration = try? self?.jsonDecoder.decode(ConfigurationResponse.self, from: data) {
|
||||
guard configuration.shouldUpdateApp else { return }
|
||||
DispatchQueue.main.async { self?.shouldUpdateApp = true }
|
||||
DispatchQueue.main.async {
|
||||
Defaults.didReceiveShouldUpdateAppNotification = true
|
||||
self?.shouldUpdateApp = true
|
||||
}
|
||||
}
|
||||
}
|
||||
dataTask.resume()
|
||||
|
Loading…
Reference in New Issue
Block a user