Change so that we always refresh after updating sync service credentials. Fixes #2713

This commit is contained in:
Maurice Parker 2021-01-09 15:15:14 -06:00
parent a88afc77d5
commit fa3d76d034
8 changed files with 60 additions and 83 deletions

View File

@ -90,10 +90,8 @@ class AccountsFeedWranglerWindowController: NSWindowController {
self.errorMessageLabel.stringValue = NSLocalizedString("Invalid email/password combination.", comment: "Credentials Error")
return
}
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .feedWrangler)
newAccount = true
}
do {
@ -101,16 +99,16 @@ class AccountsFeedWranglerWindowController: NSWindowController {
try self.account?.removeCredentials(type: .feedWranglerToken)
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
}
self.hostWindow?.endSheet(self.window!, returnCode: NSApplication.ModalResponse.OK)
} catch {
self.errorMessageLabel.stringValue = NSLocalizedString("Keychain error while storing credentials.", comment: "Credentials Error")

View File

@ -93,25 +93,23 @@ class AccountsFeedbinWindowController: NSWindowController {
return
}
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .feedbin)
newAccount = true
}
do {
try self.account?.removeCredentials(type: .basic)
try self.account?.storeCredentials(validatedCredentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
}
self.hostWindow?.endSheet(self.window!, returnCode: NSApplication.ModalResponse.OK)
} catch {
self.errorMessageLabel.stringValue = NSLocalizedString("Keychain error while storing credentials.", comment: "Credentials Error")

View File

@ -90,10 +90,9 @@ class AccountsNewsBlurWindowController: NSWindowController {
self.errorMessageLabel.stringValue = NSLocalizedString("Invalid email/password combination.", comment: "Credentials Error")
return
}
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .newsBlur)
newAccount = true
}
do {
@ -101,16 +100,16 @@ class AccountsNewsBlurWindowController: NSWindowController {
try self.account?.removeCredentials(type: .newsBlurSessionId)
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
}
self.hostWindow?.endSheet(self.window!, returnCode: NSApplication.ModalResponse.OK)
} catch {
self.errorMessageLabel.stringValue = NSLocalizedString("Keychain error while storing credentials.", comment: "Credentials Error")

View File

@ -144,11 +144,8 @@ class AccountsReaderAPIWindowController: NSWindowController {
return
}
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: self.accountType!)
newAccount = true
}
do {
@ -159,16 +156,15 @@ class AccountsReaderAPIWindowController: NSWindowController {
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
}
self.hostWindow?.endSheet(self.window!, returnCode: NSApplication.ModalResponse.OK)
} catch {
self.errorMessageLabel.stringValue = NSLocalizedString("Keychain error while storing credentials.", comment: "Credentials Error")

View File

@ -109,10 +109,8 @@ class FeedWranglerAccountViewController: UITableViewController {
return
}
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .feedWrangler)
newAccount = true
}
do {
@ -121,14 +119,12 @@ class FeedWranglerAccountViewController: UITableViewController {
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
if newAccount {
self.account?.refreshAll { result in
switch result {
case .success:
break
case .failure(let error):
self.presentError(error)
}
self.account?.refreshAll { result in
switch result {
case .success:
break
case .failure(let error):
self.presentError(error)
}
}

View File

@ -106,10 +106,8 @@ class FeedbinAccountViewController: UITableViewController {
switch result {
case .success(let credentials):
if let credentials = credentials {
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .feedbin)
newAccount = true
}
do {
@ -119,14 +117,12 @@ class FeedbinAccountViewController: UITableViewController {
} catch {}
try self.account?.storeCredentials(credentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
self.presentError(error)
}
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
self.presentError(error)
}
}

View File

@ -108,10 +108,9 @@ class NewsBlurAccountViewController: UITableViewController {
switch result {
case .success(let sessionCredentials):
if let sessionCredentials = sessionCredentials {
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: .newsBlur)
newAccount = true
}
do {
@ -123,14 +122,12 @@ class NewsBlurAccountViewController: UITableViewController {
try self.account?.storeCredentials(basicCredentials)
try self.account?.storeCredentials(sessionCredentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
self.presentError(error)
}
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
self.presentError(error)
}
}

View File

@ -159,30 +159,27 @@ class ReaderAPIAccountViewController: UITableViewController {
switch result {
case .success(let validatedCredentials):
if let validatedCredentials = validatedCredentials {
var newAccount = false
if self.account == nil {
self.account = AccountManager.shared.createAccount(type: type)
newAccount = true
}
do {
self.account?.endpointURL = url
try self.account?.removeCredentials(type: .readerBasic)
try self.account?.removeCredentials(type: .readerAPIKey)
try? self.account?.removeCredentials(type: .readerBasic)
try? self.account?.removeCredentials(type: .readerAPIKey)
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
self.dismiss(animated: true, completion: nil)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
self.showError(NSLocalizedString(error.localizedDescription, comment: "Accoount Refresh Error"))
}
self.account?.refreshAll() { result in
switch result {
case .success:
break
case .failure(let error):
self.showError(NSLocalizedString(error.localizedDescription, comment: "Accoount Refresh Error"))
}
}