diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedWranglerViewModel.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedWranglerViewModel.swift new file mode 100644 index 000000000..094f0d091 --- /dev/null +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedWranglerViewModel.swift @@ -0,0 +1,21 @@ +// +// AddFeedWranglerViewModel.swift +// Multiplatform macOS +// +// Created by Stuart Breckenridge on 05/12/2020. +// Copyright © 2020 Ranchero Software. All rights reserved. +// + +import SwiftUI +import Account +import RSCore +import RSWeb +import Secrets + +class AddFeedWranglerViewModel: ObservableObject { + @Published var isAuthenticating: Bool = false + @Published var accountUpdateError: AccountUpdateErrors = .none + @Published var showError: Bool = false + @Published var username: String = "" + @Published var password: String = "" +} diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedbinViewModel.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedbinViewModel.swift new file mode 100644 index 000000000..b0e39b393 --- /dev/null +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedbinViewModel.swift @@ -0,0 +1,21 @@ +// +// AddFeedbinViewModel.swift +// Multiplatform macOS +// +// Created by Stuart Breckenridge on 05/12/2020. +// Copyright © 2020 Ranchero Software. All rights reserved. +// + +import SwiftUI +import Account +import RSCore +import RSWeb +import Secrets + +class AddFeedbinViewModel: ObservableObject { + @Published var isAuthenticating: Bool = false + @Published var accountUpdateError: AccountUpdateErrors = .none + @Published var showError: Bool = false + @Published var username: String = "" + @Published var password: String = "" +} diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedlyViewModel.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedlyViewModel.swift new file mode 100644 index 000000000..2c96c6856 --- /dev/null +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddFeedlyViewModel.swift @@ -0,0 +1,55 @@ +// +// AddFeedlyViewModel.swift +// Multiplatform macOS +// +// Created by Stuart Breckenridge on 05/12/2020. +// Copyright © 2020 Ranchero Software. All rights reserved. +// + +import SwiftUI +import Account +import RSCore +import RSWeb +import Secrets + +class AddFeedlyViewModel: ObservableObject, OAuthAccountAuthorizationOperationDelegate { + @Published var isAuthenticating: Bool = false + @Published var accountUpdateError: AccountUpdateErrors = .none + @Published var showError: Bool = false + @Published var username: String = "" + @Published var password: String = "" + + func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { + + isAuthenticating = false + + // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. + // Ensure the app is in the foreground so the user can see their Feedly account load. + #if os(macOS) + NSApplication.shared.activate(ignoringOtherApps: true) + #endif + + account.refreshAll { [weak self] result in + switch result { + case .success: + break + case .failure(let error): + self?.accountUpdateError = .other(error: error) + self?.showError = true + } + } + } + + func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { + isAuthenticating = false + + // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. + // Ensure the app is in the foreground so the user can see the error. + #if os(macOS) + NSApplication.shared.activate(ignoringOtherApps: true) + #endif + + accountUpdateError = .other(error: error) + showError = true + } +} diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddNewsBlurViewModel.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddNewsBlurViewModel.swift new file mode 100644 index 000000000..9769afbc9 --- /dev/null +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddNewsBlurViewModel.swift @@ -0,0 +1,21 @@ +// +// AddNewsBlurViewModel.swift +// Multiplatform macOS +// +// Created by Stuart Breckenridge on 05/12/2020. +// Copyright © 2020 Ranchero Software. All rights reserved. +// + +import SwiftUI +import Account +import RSCore +import RSWeb +import Secrets + +class AddNewsBlurViewModel: ObservableObject { + @Published var isAuthenticating: Bool = false + @Published var accountUpdateError: AccountUpdateErrors = .none + @Published var showError: Bool = false + @Published var username: String = "" + @Published var password: String = "" +} diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddReaderAPIViewModel.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddReaderAPIViewModel.swift new file mode 100644 index 000000000..95663ad1d --- /dev/null +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Models/AddReaderAPIViewModel.swift @@ -0,0 +1,22 @@ +// +// AddReaderAPIViewModel.swift +// Multiplatform macOS +// +// Created by Stuart Breckenridge on 05/12/2020. +// Copyright © 2020 Ranchero Software. All rights reserved. +// + +import SwiftUI +import Account +import RSCore +import RSWeb +import Secrets + +class AddReaderAPIViewModel: ObservableObject { + @Published var isAuthenticating: Bool = false + @Published var accountUpdateError: AccountUpdateErrors = .none + @Published var showError: Bool = false + @Published var username: String = "" + @Published var password: String = "" + @Published var apiUrl: String = "" +} diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddCloudKitAccountView.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddCloudKitAccountView.swift similarity index 100% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddCloudKitAccountView.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddCloudKitAccountView.swift diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedWranglerAccountView.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedWranglerAccountView.swift similarity index 91% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedWranglerAccountView.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedWranglerAccountView.swift index a74b3748c..ebb096ff1 100644 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedWranglerAccountView.swift +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedWranglerAccountView.swift @@ -12,18 +12,11 @@ import RSCore import RSWeb import Secrets -fileprivate class AddFeedWrangerViewModel: ObservableObject { - @Published var isAuthenticating: Bool = false - @Published var accountUpdateError: AccountUpdateErrors = .none - @Published var showError: Bool = false - @Published var username: String = "" - @Published var password: String = "" -} struct AddFeedWranglerAccountView: View { @Environment (\.presentationMode) var presentationMode - @StateObject private var model = AddFeedWrangerViewModel() + @StateObject private var model = AddFeedWranglerViewModel() var body: some View { VStack { diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedbinAccountView.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedbinAccountView.swift similarity index 93% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedbinAccountView.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedbinAccountView.swift index 9c8ed94c1..71710ac78 100644 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedbinAccountView.swift +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedbinAccountView.swift @@ -12,14 +12,6 @@ import RSCore import RSWeb import Secrets -fileprivate class AddFeedbinViewModel: ObservableObject { - @Published var isAuthenticating: Bool = false - @Published var accountUpdateError: AccountUpdateErrors = .none - @Published var showError: Bool = false - @Published var username: String = "" - @Published var password: String = "" -} - struct AddFeedbinAccountView: View { @Environment (\.presentationMode) var presentationMode diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedlyAccountView.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedlyAccountView.swift similarity index 61% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedlyAccountView.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedlyAccountView.swift index 25a806da9..fb5941d6e 100644 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddFeedlyAccountView.swift +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddFeedlyAccountView.swift @@ -12,48 +12,6 @@ import RSCore import RSWeb import Secrets -fileprivate class AddFeedlyViewModel: ObservableObject, OAuthAccountAuthorizationOperationDelegate { - @Published var isAuthenticating: Bool = false - @Published var accountUpdateError: AccountUpdateErrors = .none - @Published var showError: Bool = false - @Published var username: String = "" - @Published var password: String = "" - - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { - - isAuthenticating = false - - // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. - // Ensure the app is in the foreground so the user can see their Feedly account load. - #if os(macOS) - NSApplication.shared.activate(ignoringOtherApps: true) - #endif - - account.refreshAll { [weak self] result in - switch result { - case .success: - break - case .failure(let error): - self?.accountUpdateError = .other(error: error) - self?.showError = true - } - } - } - - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { - isAuthenticating = false - - // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. - // Ensure the app is in the foreground so the user can see the error. - #if os(macOS) - NSApplication.shared.activate(ignoringOtherApps: true) - #endif - - accountUpdateError = .other(error: error) - showError = true - } -} - struct AddFeedlyAccountView: View { @Environment (\.presentationMode) var presentationMode diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddLocalAccountView.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddLocalAccountView.swift similarity index 100% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddLocalAccountView.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddLocalAccountView.swift diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddNewsBlurAccountView.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddNewsBlurAccountView.swift similarity index 93% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddNewsBlurAccountView.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddNewsBlurAccountView.swift index cfc56cd32..c2e2771ff 100644 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddNewsBlurAccountView.swift +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddNewsBlurAccountView.swift @@ -12,15 +12,6 @@ import RSCore import RSWeb import Secrets -fileprivate class AddNewsBlurViewModel: ObservableObject { - @Published var isAuthenticating: Bool = false - @Published var accountUpdateError: AccountUpdateErrors = .none - @Published var showError: Bool = false - @Published var username: String = "" - @Published var password: String = "" -} - - struct AddNewsBlurAccountView: View { @Environment (\.presentationMode) var presentationMode diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddReaderAPIAccountView.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddReaderAPIAccountView.swift similarity index 95% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddReaderAPIAccountView.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddReaderAPIAccountView.swift index c6c7a388c..aac6c8991 100644 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/AddReaderAPIAccountView.swift +++ b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/AddReaderAPIAccountView.swift @@ -12,15 +12,6 @@ import RSCore import RSWeb import Secrets -fileprivate class AddReaderAPIViewModel: ObservableObject { - @Published var isAuthenticating: Bool = false - @Published var accountUpdateError: AccountUpdateErrors = .none - @Published var showError: Bool = false - @Published var username: String = "" - @Published var password: String = "" - @Published var apiUrl: String = "" -} - struct AddReaderAPIAccountView: View { @Environment (\.presentationMode) var presentationMode diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/Authentication.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/Authentication.swift similarity index 100% rename from Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Sheets/Authentication.swift rename to Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/Add Account Sheets/Authentication.swift diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountModel.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountModel.swift deleted file mode 100644 index 61041526b..000000000 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountModel.swift +++ /dev/null @@ -1,348 +0,0 @@ -// -// AddAccountModel.swift -// Multiplatform macOS -// -// Created by Stuart Breckenridge on 13/7/20. -// Copyright © 2020 Ranchero Software. All rights reserved. -// - -import Foundation -import Account -import RSWeb -import Secrets -import RSCore - -class AddAccountModel: ObservableObject { - - let addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly, .feedWrangler, .freshRSS, .cloudKit, .newsBlur, .bazQux, .inoreader, .theOldReader] - - // Add Accounts - @Published var selectedAddAccount: AccountType = .onMyMac - @Published var userName: String = "" - @Published var password: String = "" - @Published var apiUrl: String = "" - @Published var newLocalAccountName: String = "" - @Published var accountIsAuthenticating: Bool = false - @Published var addAccountError: AccountUpdateErrors = .none { - didSet { - if addAccountError == .none { - showError = false - } else { - showError = true - } - } - } - @Published var showError: Bool = false - @Published var accountAdded: Bool = false - - func resetUserEntries() { - userName = "" - password = "" - newLocalAccountName = "" - apiUrl = "" - } - - func authenticateAccount() { - switch selectedAddAccount { - case .onMyMac: - addLocalAccount() - case .cloudKit: - authenticateCloudKit() - case .feedbin: - authenticateFeedbin() - case .feedWrangler: - authenticateFeedWrangler() - case .freshRSS, .inoreader, .bazQux, .theOldReader: - authenticateReaderAccount(selectedAddAccount) - case .feedly: - authenticateFeedly() - case .newsBlur: - authenticateNewsBlur() - } - } - -} - -// MARK:- Authentication APIs - -extension AddAccountModel { - - private func addLocalAccount() { - let account = AccountManager.shared.createAccount(type: .onMyMac) - account.name = newLocalAccountName - accountAdded = true - } - - private func authenticateFeedbin() { - accountIsAuthenticating = true - let credentials = Credentials(type: .basic, username: userName, secret: password) - - Account.validateCredentials(type: .feedbin, credentials: credentials) { [weak self] result in - - guard let self = self else { return } - - self.accountIsAuthenticating = false - - switch result { - case .success(let validatedCredentials): - - guard let validatedCredentials = validatedCredentials else { - self.addAccountError = .invalidUsernamePassword - return - } - - let account = AccountManager.shared.createAccount(type: .feedbin) - - do { - try account.removeCredentials(type: .basic) - try account.storeCredentials(validatedCredentials) - self.accountAdded = true - account.refreshAll(completion: { result in - switch result { - case .success: - break - case .failure(let error): - self.addAccountError = .other(error: error) - } - }) - - } catch { - self.addAccountError = .keyChainError - } - - case .failure: - self.addAccountError = .networkError - } - - } - - } - - private func authenticateFeedWrangler() { - - accountIsAuthenticating = true - let credentials = Credentials(type: .feedWranglerBasic, username: userName, secret: password) - - Account.validateCredentials(type: .feedWrangler, credentials: credentials) { [weak self] result in - - guard let self = self else { return } - - self.accountIsAuthenticating = false - - switch result { - case .success(let validatedCredentials): - - guard let validatedCredentials = validatedCredentials else { - self.addAccountError = .invalidUsernamePassword - return - } - - let account = AccountManager.shared.createAccount(type: .feedWrangler) - - do { - try account.removeCredentials(type: .feedWranglerBasic) - try account.removeCredentials(type: .feedWranglerToken) - try account.storeCredentials(credentials) - try account.storeCredentials(validatedCredentials) - self.accountAdded = true - account.refreshAll(completion: { result in - switch result { - case .success: - break - case .failure(let error): - self.addAccountError = .other(error: error) - } - }) - - } catch { - self.addAccountError = .keyChainError - } - - case .failure: - self.addAccountError = .networkError - } - } - } - - private func authenticateNewsBlur() { - accountIsAuthenticating = true - let credentials = Credentials(type: .newsBlurBasic, username: userName, secret: password) - - Account.validateCredentials(type: .newsBlur, credentials: credentials) { [weak self] result in - - guard let self = self else { return } - - self.accountIsAuthenticating = false - - switch result { - case .success(let validatedCredentials): - - guard let validatedCredentials = validatedCredentials else { - self.addAccountError = .invalidUsernamePassword - return - } - - let account = AccountManager.shared.createAccount(type: .newsBlur) - - do { - try account.removeCredentials(type: .newsBlurBasic) - try account.removeCredentials(type: .newsBlurSessionId) - try account.storeCredentials(credentials) - try account.storeCredentials(validatedCredentials) - self.accountAdded = true - account.refreshAll(completion: { result in - switch result { - case .success: - break - case .failure(let error): - self.addAccountError = .other(error: error) - } - }) - - } catch { - self.addAccountError = .keyChainError - } - - case .failure: - self.addAccountError = .networkError - } - } - - } - - private func authenticateReaderAccount(_ accountType: AccountType) { - accountIsAuthenticating = true - let credentials = Credentials(type: .readerBasic, username: userName, secret: password) - - if accountType == .freshRSS { - Account.validateCredentials(type: accountType, credentials: credentials, endpoint: URL(string: apiUrl)!) { [weak self] result in - - guard let self = self else { return } - - self.accountIsAuthenticating = false - - switch result { - case .success(let validatedCredentials): - - guard let validatedCredentials = validatedCredentials else { - self.addAccountError = .invalidUsernamePassword - return - } - - let account = AccountManager.shared.createAccount(type: .freshRSS) - - do { - try account.removeCredentials(type: .readerBasic) - try account.removeCredentials(type: .readerAPIKey) - try account.storeCredentials(credentials) - try account.storeCredentials(validatedCredentials) - self.accountAdded = true - account.refreshAll(completion: { result in - switch result { - case .success: - break - case .failure(let error): - self.addAccountError = .other(error: error) - } - }) - - } catch { - self.addAccountError = .keyChainError - } - - case .failure: - self.addAccountError = .networkError - } - } - } else { - - Account.validateCredentials(type: accountType, credentials: credentials) { [weak self] result in - - guard let self = self else { return } - - self.accountIsAuthenticating = false - - switch result { - case .success(let validatedCredentials): - - guard let validatedCredentials = validatedCredentials else { - self.addAccountError = .invalidUsernamePassword - return - } - - let account = AccountManager.shared.createAccount(type: .freshRSS) - - do { - try account.removeCredentials(type: .readerBasic) - try account.removeCredentials(type: .readerAPIKey) - try account.storeCredentials(credentials) - try account.storeCredentials(validatedCredentials) - self.accountAdded = true - account.refreshAll(completion: { result in - switch result { - case .success: - break - case .failure(let error): - self.addAccountError = .other(error: error) - } - }) - - } catch { - self.addAccountError = .keyChainError - } - - case .failure: - self.addAccountError = .networkError - } - } - - } - - } - - private func authenticateCloudKit() { - let _ = AccountManager.shared.createAccount(type: .cloudKit) - self.accountAdded = true - } - - private func authenticateFeedly() { - accountIsAuthenticating = true - let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly) - addAccount.delegate = self - addAccount.presentationAnchor = NSApplication.shared.windows.last - MainThreadOperationQueue.shared.add(addAccount) - } - -} - -// MARK:- OAuthAccountAuthorizationOperationDelegate -extension AddAccountModel: OAuthAccountAuthorizationOperationDelegate { - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didCreate account: Account) { - - accountIsAuthenticating = false - accountAdded = true - - // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. - // Ensure the app is in the foreground so the user can see their Feedly account load. - NSApplication.shared.activate(ignoringOtherApps: true) - - account.refreshAll { [weak self] result in - switch result { - case .success: - break - case .failure(let error): - self?.addAccountError = .other(error: error) - } - } - } - - func oauthAccountAuthorizationOperation(_ operation: OAuthAccountAuthorizationOperation, didFailWith error: Error) { - accountIsAuthenticating = false - - // macOS only: `ASWebAuthenticationSession` leaves the browser in the foreground. - // Ensure the app is in the foreground so the user can see the error. - NSApplication.shared.activate(ignoringOtherApps: true) - - addAccountError = .other(error: error) - } -} diff --git a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountPickerRow.swift b/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountPickerRow.swift deleted file mode 100644 index 7a5ca0fe7..000000000 --- a/Multiplatform/macOS/Preferences/Preference Panes/Accounts/Account Preferences/Add Account/AddAccountPickerRow.swift +++ /dev/null @@ -1,55 +0,0 @@ -// -// AddAccountPickerRow.swift -// Multiplatform macOS -// -// Created by Stuart Breckenridge on 13/7/20. -// Copyright © 2020 Ranchero Software. All rights reserved. -// - -import SwiftUI -import Account - -struct AddAccountPickerRow: View { - - var accountType: AccountType - - var body: some View { - HStack { -// if let img = AppAssets.image(for: accountType) { -// Image(rsImage: img) -// .resizable() -// .aspectRatio(contentMode: .fit) -// .frame(width: 15, height: 15) -// } - - switch accountType { - case .onMyMac: - Text(Account.defaultLocalAccountName) - case .cloudKit: - Text("iCloud") - case .inoreader: - Text("Inoreader") - case .theOldReader: - Text("The Old Reader") - case .bazQux: - Text("BazQux") - case .feedbin: - Text("Feedbin") - case .feedWrangler: - Text("FeedWrangler") - case .freshRSS: - Text("FreshRSS") - case .feedly: - Text("Feedly") - case .newsBlur: - Text("NewsBlur") - } - } - } -} - -struct AddAccountPickerRow_Previews: PreviewProvider { - static var previews: some View { - AddAccountPickerRow(accountType: .onMyMac) - } -} diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index d862ea005..ff440add3 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -29,6 +29,11 @@ 172199ED24AB2E0100A31D04 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199EC24AB2E0100A31D04 /* SafariView.swift */; }; 172199F124AB716900A31D04 /* SidebarToolbarModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172199F024AB716900A31D04 /* SidebarToolbarModifier.swift */; }; 17241249257B8A8A00ACCEBC /* AddFeedlyAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17241248257B8A8A00ACCEBC /* AddFeedlyAccountView.swift */; }; + 1724126A257BBEBB00ACCEBC /* AddFeedbinViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17241269257BBEBB00ACCEBC /* AddFeedbinViewModel.swift */; }; + 17241278257BBEE700ACCEBC /* AddFeedlyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17241277257BBEE700ACCEBC /* AddFeedlyViewModel.swift */; }; + 17241280257BBF3E00ACCEBC /* AddFeedWranglerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1724127F257BBF3E00ACCEBC /* AddFeedWranglerViewModel.swift */; }; + 17241288257BBF7000ACCEBC /* AddNewsBlurViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17241287257BBF7000ACCEBC /* AddNewsBlurViewModel.swift */; }; + 17241290257BBFAD00ACCEBC /* AddReaderAPIViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1724128F257BBFAD00ACCEBC /* AddReaderAPIViewModel.swift */; }; 1727B39924C1368D00A4DBDC /* LayoutPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1727B39824C1368D00A4DBDC /* LayoutPreferencesView.swift */; }; 1729529324AA1CAA00D65E66 /* AccountsPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529024AA1CAA00D65E66 /* AccountsPreferencesView.swift */; }; 1729529424AA1CAA00D65E66 /* AdvancedPreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1729529124AA1CAA00D65E66 /* AdvancedPreferencesView.swift */; }; @@ -76,8 +81,6 @@ 1768147B2564BE5400D98635 /* widget-sample.json in Resources */ = {isa = PBXBuildFile; fileRef = 1768147A2564BE5400D98635 /* widget-sample.json */; }; 1769E32224BC5925000E1E8E /* AccountsPreferencesModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1769E32124BC5925000E1E8E /* AccountsPreferencesModel.swift */; }; 1769E32524BC5A65000E1E8E /* AddAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1769E32424BC5A65000E1E8E /* AddAccountView.swift */; }; - 1769E32724BC5B6C000E1E8E /* AddAccountModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1769E32624BC5B6C000E1E8E /* AddAccountModel.swift */; }; - 1769E32924BCAFC7000E1E8E /* AddAccountPickerRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1769E32824BCAFC7000E1E8E /* AddAccountPickerRow.swift */; }; 1769E32B24BCB030000E1E8E /* ConfiguredAccountRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1769E32A24BCB030000E1E8E /* ConfiguredAccountRow.swift */; }; 1769E32D24BD20A0000E1E8E /* AccountDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1769E32C24BD20A0000E1E8E /* AccountDetailView.swift */; }; 1769E33024BD6271000E1E8E /* EditAccountCredentialsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1769E32F24BD6271000E1E8E /* EditAccountCredentialsView.swift */; }; @@ -1355,6 +1358,11 @@ 172199EC24AB2E0100A31D04 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = ""; }; 172199F024AB716900A31D04 /* SidebarToolbarModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarToolbarModifier.swift; sourceTree = ""; }; 17241248257B8A8A00ACCEBC /* AddFeedlyAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeedlyAccountView.swift; sourceTree = ""; }; + 17241269257BBEBB00ACCEBC /* AddFeedbinViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeedbinViewModel.swift; sourceTree = ""; }; + 17241277257BBEE700ACCEBC /* AddFeedlyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeedlyViewModel.swift; sourceTree = ""; }; + 1724127F257BBF3E00ACCEBC /* AddFeedWranglerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddFeedWranglerViewModel.swift; sourceTree = ""; }; + 17241287257BBF7000ACCEBC /* AddNewsBlurViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddNewsBlurViewModel.swift; sourceTree = ""; }; + 1724128F257BBFAD00ACCEBC /* AddReaderAPIViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddReaderAPIViewModel.swift; sourceTree = ""; }; 1727B39824C1368D00A4DBDC /* LayoutPreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutPreferencesView.swift; sourceTree = ""; }; 1729529024AA1CAA00D65E66 /* AccountsPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsPreferencesView.swift; sourceTree = ""; }; 1729529124AA1CAA00D65E66 /* AdvancedPreferencesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvancedPreferencesView.swift; sourceTree = ""; }; @@ -1385,8 +1393,6 @@ 176814822564C02A00D98635 /* NetNewsWire_iOS_WidgetExtension.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = NetNewsWire_iOS_WidgetExtension.entitlements; sourceTree = ""; }; 1769E32124BC5925000E1E8E /* AccountsPreferencesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsPreferencesModel.swift; sourceTree = ""; }; 1769E32424BC5A65000E1E8E /* AddAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountView.swift; sourceTree = ""; }; - 1769E32624BC5B6C000E1E8E /* AddAccountModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountModel.swift; sourceTree = ""; }; - 1769E32824BCAFC7000E1E8E /* AddAccountPickerRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddAccountPickerRow.swift; sourceTree = ""; }; 1769E32A24BCB030000E1E8E /* ConfiguredAccountRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfiguredAccountRow.swift; sourceTree = ""; }; 1769E32C24BD20A0000E1E8E /* AccountDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountDetailView.swift; sourceTree = ""; }; 1769E32F24BD6271000E1E8E /* EditAccountCredentialsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditAccountCredentialsView.swift; sourceTree = ""; }; @@ -2112,6 +2118,18 @@ path = Settings; sourceTree = ""; }; + 17241268257BBE7B00ACCEBC /* Add Account Models */ = { + isa = PBXGroup; + children = ( + 17241269257BBEBB00ACCEBC /* AddFeedbinViewModel.swift */, + 17241277257BBEE700ACCEBC /* AddFeedlyViewModel.swift */, + 1724127F257BBF3E00ACCEBC /* AddFeedWranglerViewModel.swift */, + 17241287257BBF7000ACCEBC /* AddNewsBlurViewModel.swift */, + 1724128F257BBFAD00ACCEBC /* AddReaderAPIViewModel.swift */, + ); + path = "Add Account Models"; + sourceTree = ""; + }; 1727B37624C1365300A4DBDC /* Viewing */ = { isa = PBXGroup; children = ( @@ -2140,7 +2158,7 @@ path = "Preference Panes"; sourceTree = ""; }; - 17386B812577C4C60014C8B2 /* Sheets */ = { + 17386B812577C4C60014C8B2 /* Add Account Sheets */ = { isa = PBXGroup; children = ( 17386B792577C4BF0014C8B2 /* AddLocalAccountView.swift */, @@ -2151,7 +2169,7 @@ DF98E2BD2578AC0000F18944 /* AddNewsBlurAccountView.swift */, DF98E2C52578AD1B00F18944 /* AddReaderAPIAccountView.swift */, ); - path = Sheets; + path = "Add Account Sheets"; sourceTree = ""; }; 176813A22564B9D100D98635 /* Widget */ = { @@ -2240,10 +2258,9 @@ 1769E32324BC5A50000E1E8E /* Add Account */ = { isa = PBXGroup; children = ( - 1769E32624BC5B6C000E1E8E /* AddAccountModel.swift */, 1769E32424BC5A65000E1E8E /* AddAccountView.swift */, - 1769E32824BCAFC7000E1E8E /* AddAccountPickerRow.swift */, - 17386B812577C4C60014C8B2 /* Sheets */, + 17241268257BBE7B00ACCEBC /* Add Account Models */, + 17386B812577C4C60014C8B2 /* Add Account Sheets */, ); path = "Add Account"; sourceTree = ""; @@ -4653,13 +4670,13 @@ 51B80F4224BE588200C6C32D /* SharingServicePickerDelegate.swift in Sources */, 51E4990624A808C300B667CB /* ImageDownloader.swift in Sources */, 51E4994F24A8734C00B667CB /* TwitterFeedProvider-Extensions.swift in Sources */, + 17241280257BBF3E00ACCEBC /* AddFeedWranglerViewModel.swift in Sources */, 51E498CA24A8085D00B667CB /* SmartFeedDelegate.swift in Sources */, DF98E2B02578AA5C00F18944 /* AddFeedWranglerAccountView.swift in Sources */, 5177470A24B2F87600EB0F74 /* SidebarListStyleModifier.swift in Sources */, 1769E33824BD97CB000E1E8E /* AccountUpdateErrors.swift in Sources */, 51E4990524A808C300B667CB /* FeaturedImageDownloader.swift in Sources */, 5181C5AE24AF89B1002E0F70 /* PreferredColorSchemeModifier.swift in Sources */, - 1769E32924BCAFC7000E1E8E /* AddAccountPickerRow.swift in Sources */, 1769E32224BC5925000E1E8E /* AccountsPreferencesModel.swift in Sources */, 51E4991624A8090300B667CB /* ArticleUtilities.swift in Sources */, 51919FF224AB864A00541E64 /* TimelineModel.swift in Sources */, @@ -4688,11 +4705,14 @@ 1769E32524BC5A65000E1E8E /* AddAccountView.swift in Sources */, 51E4994A24A8734C00B667CB /* ExtensionPointManager.swift in Sources */, 514E6C0324AD29A300AC6F6E /* TimelineItemStatusView.swift in Sources */, + 1724126A257BBEBB00ACCEBC /* AddFeedbinViewModel.swift in Sources */, 51B54A6524B549B20014348B /* WrapperScriptMessageHandler.swift in Sources */, 51E4996D24A8762D00B667CB /* ArticleExtractor.swift in Sources */, 1704053524E5985A00A00787 /* SceneNavigationModel.swift in Sources */, + 17241278257BBEE700ACCEBC /* AddFeedlyViewModel.swift in Sources */, 51E4994024A8713B00B667CB /* AccountRefreshTimer.swift in Sources */, 51E49A0424A91FF600B667CB /* SceneNavigationView.swift in Sources */, + 17241290257BBFAD00ACCEBC /* AddReaderAPIViewModel.swift in Sources */, 51E498CC24A8085D00B667CB /* SearchFeedDelegate.swift in Sources */, 51E498C824A8085D00B667CB /* SmartFeedsController.swift in Sources */, 175942AB24AD533200585066 /* RefreshInterval.swift in Sources */, @@ -4704,6 +4724,7 @@ DF98E29A2578A73A00F18944 /* AddCloudKitAccountView.swift in Sources */, 51E498FB24A808BA00B667CB /* FaviconGenerator.swift in Sources */, 17D5F19524B0C1DD00375168 /* SidebarToolbarModifier.swift in Sources */, + 17241288257BBF7000ACCEBC /* AddNewsBlurViewModel.swift in Sources */, 51E4996724A8760B00B667CB /* ArticleStylesManager.swift in Sources */, 1729529B24AA1FD200D65E66 /* MacSearchField.swift in Sources */, 51408B7F24A9EC6F0073CF4E /* SidebarItem.swift in Sources */, @@ -4742,7 +4763,6 @@ 514E6C0024AD255D00AC6F6E /* PreviewArticles.swift in Sources */, 51C4CFF424D37D1F00AF9874 /* Secrets.swift in Sources */, 1729529524AA1CAA00D65E66 /* GeneralPreferencesView.swift in Sources */, - 1769E32724BC5B6C000E1E8E /* AddAccountModel.swift in Sources */, 1729529424AA1CAA00D65E66 /* AdvancedPreferencesView.swift in Sources */, 5177470424B2657F00EB0F74 /* TimelineToolbarModifier.swift in Sources */, 51A8001324CA0FC700F41F1D /* Sink.swift in Sources */,