Fix login on Catalyst

This commit is contained in:
Thomas Ricouard 2023-10-26 17:47:19 +02:00
parent 2a936adca0
commit 5a52eb50e9

View file

@ -13,6 +13,7 @@ import SwiftUI
struct AddAccountView: View { struct AddAccountView: View {
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@Environment(\.scenePhase) private var scenePhase @Environment(\.scenePhase) private var scenePhase
@Environment(\.openURL) private var openURL
@Environment(AppAccountsManager.self) private var appAccountsManager @Environment(AppAccountsManager.self) private var appAccountsManager
@Environment(CurrentAccount.self) private var currentAccount @Environment(CurrentAccount.self) private var currentAccount
@ -145,9 +146,11 @@ struct AddAccountView: View {
isSigninIn = false isSigninIn = false
} }
} }
#if !targetEnvironment(macCatalyst)
.sheet(item: $oauthURL, content: { url in .sheet(item: $oauthURL, content: { url in
SafariView(url: url) SafariView(url: url)
}) })
#endif
} }
} }
@ -230,7 +233,11 @@ struct AddAccountView: View {
do { do {
signInClient = .init(server: sanitizedName) signInClient = .init(server: sanitizedName)
if let oauthURL = try await signInClient?.oauthURL() { if let oauthURL = try await signInClient?.oauthURL() {
self.oauthURL = oauthURL if ProcessInfo.processInfo.isMacCatalystApp {
openURL(oauthURL)
} else {
self.oauthURL = oauthURL
}
} else { } else {
isSigninIn = false isSigninIn = false
} }