mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Adds Error Display for the handle(_: URL) function
Additionally, shortens validation code in AddAccount
This commit is contained in:
@@ -60,21 +60,12 @@ struct NewsBlurAddAccountView: View, Logging {
|
||||
|
||||
func retreiveCredentials() {
|
||||
if let account = account {
|
||||
do {
|
||||
let credentials = try account.retrieveCredentials(type: .newsBlurBasic)
|
||||
if let credentials = credentials {
|
||||
self.accountUserName = credentials.username
|
||||
self.accountPassword = credentials.secret
|
||||
} else {
|
||||
print("No cred")
|
||||
}
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
let credentials = try? account.retrieveCredentials(type: .newsBlurBasic)
|
||||
if let credentials = credentials {
|
||||
self.accountUserName = credentials.username
|
||||
self.accountPassword = credentials.secret
|
||||
}
|
||||
} else {
|
||||
print("No account")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var accountDetails: some View {
|
||||
|
||||
@@ -26,6 +26,11 @@ struct EnableExtensionPointView: View {
|
||||
}, message: {
|
||||
Text(extensionError.0?.localizedDescription ?? "Unknown Error")
|
||||
})
|
||||
.alert(Text("Error", comment: "Alert title: Error"), isPresented: $viewModel.showExtensionError.1, actions: {
|
||||
Button(action: {}, label: { Text("Dismiss", comment: "Button title") })
|
||||
}, message: {
|
||||
Text(viewModel.showExtensionError.0?.localizedDescription ?? "Unknown Error")
|
||||
})
|
||||
.navigationTitle(extensionPoint.title)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.dismissOnExternalContextLaunch()
|
||||
|
||||
@@ -13,9 +13,10 @@ import OAuthSwift
|
||||
import Secrets
|
||||
import RSCore
|
||||
|
||||
@MainActor
|
||||
|
||||
public final class EnableExtensionViewModel: NSObject, ObservableObject, OAuthSwiftURLHandlerType, ASWebAuthenticationPresentationContextProviding, Logging {
|
||||
|
||||
@Published public var showExtensionError: (Error?, Bool) = (nil, false)
|
||||
private var extensionPointType: ExtensionPoint.Type?
|
||||
private var oauth: OAuthSwift?
|
||||
private var callbackURL: URL? = nil
|
||||
@@ -146,7 +147,7 @@ public final class EnableExtensionViewModel: NSObject, ObservableObject, OAuthSw
|
||||
if case ASWebAuthenticationSessionError.canceledLogin = error {
|
||||
print("Login cancelled.")
|
||||
} else {
|
||||
//self.presentError(error)
|
||||
self.showExtensionError = (error, true)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user