From a4bcbf5c367ed9dd2a688688c25c63b482eea927 Mon Sep 17 00:00:00 2001 From: Kiel Gillard Date: Mon, 11 Nov 2019 08:10:39 +1100 Subject: [PATCH] Automatically refreshes a new Feedly account after its creation. --- .../Feedly/OAuthAccountAuthorizationOperation.swift | 3 +++ .../Accounts/AccountsAddViewController.swift | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift b/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift index 72e867ef5..bc73c6f3e 100644 --- a/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift +++ b/Frameworks/Account/Feedly/OAuthAccountAuthorizationOperation.swift @@ -10,6 +10,7 @@ import Foundation import AuthenticationServices public protocol OAuthAccountAuthorizationOperationDelegate: class { + func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) } @@ -126,6 +127,8 @@ public final class OAuthAccountAuthorizationOperation: Operation, ASWebAuthentic // Now store the access token because we want the account delegate to use it. try account.storeCredentials(grant.accessToken) + + delegate?.oauthAccountAuthorizationOperation(self, didCreate: account) didFinish() } catch { diff --git a/Mac/Preferences/Accounts/AccountsAddViewController.swift b/Mac/Preferences/Accounts/AccountsAddViewController.swift index 5574248ea..db0def90c 100644 --- a/Mac/Preferences/Accounts/AccountsAddViewController.swift +++ b/Mac/Preferences/Accounts/AccountsAddViewController.swift @@ -119,6 +119,17 @@ extension AccountsAddViewController: NSTableViewDelegate { extension AccountsAddViewController: OAuthAccountAuthorizationOperationDelegate { + func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { + account.refreshAll { [weak self] result in + switch result { + case .success: + break + case .failure(let error): + self?.presentError(error) + } + } + } + func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { view.window?.presentError(error) }