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,7 +99,7 @@ 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:
@ -110,7 +108,7 @@ class AccountsFeedWranglerWindowController: NSWindowController {
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,16 +93,14 @@ 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:
@ -111,7 +109,7 @@ class AccountsFeedbinWindowController: NSWindowController {
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,7 +100,7 @@ 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:
@ -110,7 +109,7 @@ class AccountsNewsBlurWindowController: NSWindowController {
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,7 +156,6 @@ class AccountsReaderAPIWindowController: NSWindowController {
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
@ -168,7 +164,7 @@ class AccountsReaderAPIWindowController: NSWindowController {
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,7 +119,6 @@ class FeedWranglerAccountViewController: UITableViewController {
try self.account?.storeCredentials(credentials)
try self.account?.storeCredentials(validatedCredentials)
if newAccount {
self.account?.refreshAll { result in
switch result {
case .success:
@ -130,7 +127,6 @@ class FeedWranglerAccountViewController: UITableViewController {
self.presentError(error)
}
}
}
self.dismiss(animated: true, completion: nil)
self.delegate?.dismiss()

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,7 +117,6 @@ class FeedbinAccountViewController: UITableViewController {
} catch {}
try self.account?.storeCredentials(credentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
@ -128,7 +125,6 @@ class FeedbinAccountViewController: UITableViewController {
self.presentError(error)
}
}
}
self.dismiss(animated: true, completion: nil)
self.delegate?.dismiss()

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,7 +122,6 @@ class NewsBlurAccountViewController: UITableViewController {
try self.account?.storeCredentials(basicCredentials)
try self.account?.storeCredentials(sessionCredentials)
if newAccount {
self.account?.refreshAll() { result in
switch result {
case .success:
@ -132,7 +130,6 @@ class NewsBlurAccountViewController: UITableViewController {
self.presentError(error)
}
}
}
self.dismiss(animated: true, completion: nil)
self.delegate?.dismiss()

View File

@ -159,23 +159,21 @@ 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:
@ -184,7 +182,6 @@ class ReaderAPIAccountViewController: UITableViewController {
self.showError(NSLocalizedString(error.localizedDescription, comment: "Accoount Refresh Error"))
}
}
}
self.delegate?.dismiss()
} catch {