mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 03:56:55 +01:00
Back out bad implementation of single threading access token renewal
This commit is contained in:
parent
26041a067f
commit
3699889b87
@ -48,7 +48,6 @@ public final class RedditFeedProvider: FeedProvider {
|
||||
return oauthSwift?.client
|
||||
}
|
||||
|
||||
private var renewingAccessToken = false
|
||||
private var rateLimitRemaining: Int?
|
||||
private var rateLimitReset: Date?
|
||||
|
||||
@ -323,19 +322,11 @@ private extension RedditFeedProvider {
|
||||
|
||||
func handleFailure(error: OAuthSwiftError, completion: @escaping (Error?) -> Void) {
|
||||
if case .tokenExpired = error {
|
||||
os_log(.debug, log: self.log, "Access token expired, attempting to renew...")
|
||||
|
||||
if renewingAccessToken {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
||||
completion(nil)
|
||||
}
|
||||
}
|
||||
|
||||
renewingAccessToken = true
|
||||
os_log(.debug, log: self.log, "Access token expired, attempting to renew...")
|
||||
|
||||
oauthSwift?.renewAccessToken(withRefreshToken: oauthRefreshToken) { [weak self] result in
|
||||
guard let strongSelf = self, let username = strongSelf.username else {
|
||||
self?.renewingAccessToken = false
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
@ -348,14 +339,11 @@ private extension RedditFeedProvider {
|
||||
try Self.storeCredentials(username: username, oauthToken: strongSelf.oauthToken, oauthRefreshToken: strongSelf.oauthRefreshToken)
|
||||
os_log(.debug, log: strongSelf.log, "Access token renewed.")
|
||||
} catch {
|
||||
strongSelf.renewingAccessToken = false
|
||||
completion(error)
|
||||
return
|
||||
}
|
||||
strongSelf.renewingAccessToken = false
|
||||
completion(nil)
|
||||
case .failure(let oathError):
|
||||
strongSelf.renewingAccessToken = false
|
||||
completion(oathError)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user