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
|
||||
static func reload() async {
|
||||
// Could be done in nicer way, but that would require iOS 17+
|
||||
await withCheckedContinuation { continuation in
|
||||
let networkPathMonitor: NWPathMonitor = NWPathMonitor()
|
||||
networkPathMonitor.pathUpdateHandler = { path in
|
||||
Task {
|
||||
if path.status != .unsatisfied {
|
||||
let userDefaults = UserDefaults.standard
|
||||
if let userPreferences = await reloadUserPreferences() {
|
||||
userDefaults.set(String(describing: userPreferences.m_displayName), forKey: userDefaultsKeyName)
|
||||
userDefaults.set(Int(userPreferences.m_changesets), forKey: userDefaultsKeyNumberOfEdits)
|
||||
} else if path.status == .satisfied {
|
||||
userDefaults.set(true, forKey: userDefaultsNeedsReauthorization)
|
||||
if isExisting {
|
||||
// Could be done in nicer way, but that would require iOS 17+
|
||||
await withCheckedContinuation { continuation in
|
||||
let networkPathMonitor: NWPathMonitor = NWPathMonitor()
|
||||
networkPathMonitor.pathUpdateHandler = { path in
|
||||
Task {
|
||||
if path.status != .unsatisfied {
|
||||
let userDefaults = UserDefaults.standard
|
||||
if let userPreferences = await reloadUserPreferences() {
|
||||
userDefaults.set(String(describing: userPreferences.m_displayName), forKey: userDefaultsKeyName)
|
||||
userDefaults.set(Int(userPreferences.m_changesets), forKey: userDefaultsKeyNumberOfEdits)
|
||||
} 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
|
||||
static func logout() {
|
||||
if isExisting {
|
||||
let userDefaults = UserDefaults.standard
|
||||
userDefaults.removeObject(forKey: userDefaultsKeyAuthorizationToken)
|
||||
userDefaults.removeObject(forKey: userDefaultsKeyName)
|
||||
userDefaults.removeObject(forKey: userDefaultsKeyNumberOfEdits)
|
||||
userDefaults.removeObject(forKey: userDefaultsNeedsReauthorization)
|
||||
}
|
||||
let userDefaults = UserDefaults.standard
|
||||
userDefaults.removeObject(forKey: userDefaultsKeyAuthorizationToken)
|
||||
userDefaults.removeObject(forKey: userDefaultsKeyName)
|
||||
userDefaults.removeObject(forKey: userDefaultsKeyNumberOfEdits)
|
||||
userDefaults.removeObject(forKey: userDefaultsNeedsReauthorization)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user