diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index f2802c5d1..fd20c7bde 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -263,9 +263,6 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, // MARK: - API public func storeCredentials(_ credentials: Credentials) throws { - // The delegate may need the credentials to determine the server - delegate.credentials = credentials - guard let server = delegate.server else { throw CredentialsError.incompleteCredentials } @@ -300,6 +297,21 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, self.username = nil } + public func retrieveGoogleAuthCredentials() throws -> Credentials? { + guard let username = self.username, let server = delegate.server else { + return nil + } + return try CredentialsManager.retrieveGoogleAuthCredentials(server: server, username: username) + } + + public func removeGoogleAuthCredentials() throws { + guard let username = self.username, let server = delegate.server else { + return + } + try CredentialsManager.removeGoogleAuthCredentials(server: server, username: username) + self.username = nil + } + public static func validateCredentials(transport: Transport = URLSession.webserviceTransport(), type: AccountType, credentials: Credentials, endpoint: URL? = nil, completion: @escaping (Result) -> Void) { switch type { case .onMyMac: diff --git a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift index 70c8ddde1..b8617f5e8 100644 --- a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift +++ b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAPICaller.swift @@ -163,7 +163,21 @@ final class GoogleReaderCompatibleAPICaller: NSObject { return } - let callURL = baseURL.appendingPathComponent("/reader/api/0/tag/list?output=json") + // Add query string for getting JSON (probably should break this out as I will be doing it a lot) + guard var components = URLComponents(url: baseURL.appendingPathComponent("/reader/api/0/tag/list"), resolvingAgainstBaseURL: false) else { + completion(.failure(TransportError.noURL)) + return + } + + components.queryItems = [ + URLQueryItem(name: "output", value: "json") + ] + + guard let callURL = components.url else { + completion(.failure(TransportError.noURL)) + return + } + //let conditionalGet = accountMetadata?.conditionalGetInfo[ConditionalGetKeys.tags] let request = URLRequest(url: callURL, credentials: credentials) diff --git a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift index e865079d9..a5b905893 100644 --- a/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift +++ b/Frameworks/Account/GoogleReaderCompatible/GoogleReaderCompatibleAccountDelegate.swift @@ -90,18 +90,22 @@ final class GoogleReaderCompatibleAccountDelegate: AccountDelegate { refreshAccount(account) { result in switch result { case .success(): - - self.refreshArticles(account) { - self.refreshArticleStatus(for: account) { - self.refreshMissingArticles(account) { - self.refreshProgress.clear() - DispatchQueue.main.async { - completion(.success(())) - } - } - } + DispatchQueue.main.async { + completion(.success(())) } + +// self.refreshArticles(account) { +// self.refreshArticleStatus(for: account) { +// self.refreshMissingArticles(account) { +// self.refreshProgress.clear() +// DispatchQueue.main.async { +// completion(.success(())) +// } +// } +// } +// } +// case .failure(let error): DispatchQueue.main.async { self.refreshProgress.clear() @@ -486,8 +490,8 @@ final class GoogleReaderCompatibleAccountDelegate: AccountDelegate { } func accountDidInitialize(_ account: Account) { - credentials = try? account.retrieveBasicCredentials() accountMetadata = account.metadata + credentials = try? account.retrieveGoogleAuthCredentials() } static func validateCredentials(transport: Transport, credentials: Credentials, endpoint: URL?, completion: @escaping (Result) -> Void) { @@ -570,7 +574,7 @@ private extension GoogleReaderCompatibleAccountDelegate { os_log(.debug, log: log, "Syncing folders with %ld tags.", tags.count) - let tagNames = tags.map { $0.name } + let tagNames = tags.map { $0.tagID } // Delete any folders not at GoogleReaderCompatible if let folders = account.folders { diff --git a/Mac/Preferences/Accounts/AccountsGoogleReaderCompatibleWindowController.swift b/Mac/Preferences/Accounts/AccountsGoogleReaderCompatibleWindowController.swift index 4ed008fe2..89db9f277 100644 --- a/Mac/Preferences/Accounts/AccountsGoogleReaderCompatibleWindowController.swift +++ b/Mac/Preferences/Accounts/AccountsGoogleReaderCompatibleWindowController.swift @@ -96,10 +96,9 @@ class AccountsGoogleReaderCompatibleWindowController: NSWindowController { do { self.account?.endpointURL = apiURL - try self.account?.removeBasicCredentials() + try self.account?.removeGoogleAuthCredentials() try self.account?.storeCredentials(validatedCredentials) - if newAccount { self.account?.refreshAll() { result in switch result { diff --git a/submodules/RSWeb b/submodules/RSWeb index f3bcd0312..cf3a30eb3 160000 --- a/submodules/RSWeb +++ b/submodules/RSWeb @@ -1 +1 @@ -Subproject commit f3bcd0312d6797e2722760c1de622e2957114802 +Subproject commit cf3a30eb3833d9dd423fed003393e6e3c1a360d4