mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[ios] Fixing reappearing login promts
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
@@ -138,37 +138,37 @@ import OSMEditor
|
|||||||
|
|
||||||
/// Reload the OpenStreetMap profile
|
/// Reload the OpenStreetMap profile
|
||||||
static func reload() async {
|
static func reload() async {
|
||||||
// Could be done in nicer way, but that would require iOS 17+
|
if isExisting {
|
||||||
await withCheckedContinuation { continuation in
|
// Could be done in nicer way, but that would require iOS 17+
|
||||||
let networkPathMonitor: NWPathMonitor = NWPathMonitor()
|
await withCheckedContinuation { continuation in
|
||||||
networkPathMonitor.pathUpdateHandler = { path in
|
let networkPathMonitor: NWPathMonitor = NWPathMonitor()
|
||||||
Task {
|
networkPathMonitor.pathUpdateHandler = { path in
|
||||||
if path.status != .unsatisfied {
|
Task {
|
||||||
let userDefaults = UserDefaults.standard
|
if path.status != .unsatisfied {
|
||||||
if let userPreferences = await reloadUserPreferences() {
|
let userDefaults = UserDefaults.standard
|
||||||
userDefaults.set(String(describing: userPreferences.m_displayName), forKey: userDefaultsKeyName)
|
if let userPreferences = await reloadUserPreferences() {
|
||||||
userDefaults.set(Int(userPreferences.m_changesets), forKey: userDefaultsKeyNumberOfEdits)
|
userDefaults.set(String(describing: userPreferences.m_displayName), forKey: userDefaultsKeyName)
|
||||||
} else if path.status == .satisfied {
|
userDefaults.set(Int(userPreferences.m_changesets), forKey: userDefaultsKeyNumberOfEdits)
|
||||||
userDefaults.set(true, forKey: userDefaultsNeedsReauthorization)
|
} else if path.status == .satisfied {
|
||||||
|
userDefaults.set(true, forKey: userDefaultsNeedsReauthorization)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
networkPathMonitor.cancel()
|
||||||
|
continuation.resume()
|
||||||
}
|
}
|
||||||
networkPathMonitor.cancel()
|
|
||||||
continuation.resume()
|
|
||||||
}
|
}
|
||||||
|
networkPathMonitor.start(queue: .main)
|
||||||
}
|
}
|
||||||
networkPathMonitor.start(queue: .main)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Logout of the OpenStreetMap profile
|
/// Logout of the OpenStreetMap profile
|
||||||
static func logout() {
|
static func logout() {
|
||||||
if isExisting {
|
let userDefaults = UserDefaults.standard
|
||||||
let userDefaults = UserDefaults.standard
|
userDefaults.removeObject(forKey: userDefaultsKeyAuthorizationToken)
|
||||||
userDefaults.removeObject(forKey: userDefaultsKeyAuthorizationToken)
|
userDefaults.removeObject(forKey: userDefaultsKeyName)
|
||||||
userDefaults.removeObject(forKey: userDefaultsKeyName)
|
userDefaults.removeObject(forKey: userDefaultsKeyNumberOfEdits)
|
||||||
userDefaults.removeObject(forKey: userDefaultsKeyNumberOfEdits)
|
userDefaults.removeObject(forKey: userDefaultsNeedsReauthorization)
|
||||||
userDefaults.removeObject(forKey: userDefaultsNeedsReauthorization)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user