Skip to content

Commit 6299568

Browse files
chore: remove dead code, handled in AccountConflictModifier
1 parent 0ee4543 commit 6299568

File tree

2 files changed

+3
-55
lines changed

2 files changed

+3
-55
lines changed

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/AccountConflictModifier.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public extension EnvironmentValues {
3232
@MainActor
3333
struct AccountConflictModifier: ViewModifier {
3434
@Environment(AuthService.self) private var authService
35+
@Environment(\.reportError) private var reportError
3536
@State private var pendingCredentialForLinking: AuthCredential?
3637

3738
func body(content: Content) -> some View {
@@ -56,11 +57,9 @@ struct AccountConflictModifier: ViewModifier {
5657

5758
// Sign in with the new credential
5859
_ = try await authService.signIn(credentials: conflict.credential)
59-
60-
// Successfully handled - conflict is cleared automatically by reset()
6160
} catch {
62-
// Error will be shown via normal error handling
63-
// Credential is still stored if they want to retry
61+
// Report error to parent view for display
62+
reportError?(error)
6463
}
6564
}
6665
} else {
@@ -81,7 +80,6 @@ struct AccountConflictModifier: ViewModifier {
8180
pendingCredentialForLinking = nil
8281
} catch {
8382
// Silently swallow linking errors - user is already signed in
84-
// Consumer's custom views can observe authService.currentError if they want to handle this
8583
pendingCredentialForLinking = nil
8684
}
8785
}

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/AuthPickerView.swift

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public struct AuthPickerView<Content: View> {
2626
@Environment(AuthService.self) private var authService
2727
private let content: () -> Content
2828

29-
// View-layer state for handling auto-linking flow
30-
@State private var pendingCredentialForLinking: AuthCredential?
3129
// View-layer error state
3230
@State private var error: AlertError?
3331
}
@@ -91,54 +89,6 @@ extension AuthPickerView: View {
9189
}
9290
}
9391

94-
/// View-layer logic: Handle account conflicts with type-specific behavior
95-
private func handleAccountConflict(_ conflict: AccountConflictContext?) {
96-
guard let conflict = conflict else { return }
97-
98-
// Only auto-handle anonymous upgrade conflicts
99-
if conflict.conflictType == .anonymousUpgradeConflict {
100-
Task {
101-
do {
102-
// Sign out the anonymous user
103-
try await authService.signOut()
104-
105-
// Sign in with the new credential
106-
_ = try await authService.signIn(credentials: conflict.credential)
107-
108-
// Successfully handled - conflict is cleared automatically by reset()
109-
} catch let caughtError {
110-
// Show error in alert
111-
reportError(caughtError)
112-
}
113-
}
114-
} else {
115-
// Other conflicts: store credential for potential linking after sign-in
116-
pendingCredentialForLinking = conflict.credential
117-
// Show error modal for user to see and handle
118-
error = AlertError(
119-
message: conflict.message,
120-
underlyingError: conflict.underlyingError
121-
)
122-
}
123-
}
124-
125-
/// View-layer logic: Attempt to link pending credential after successful sign-in
126-
private func attemptAutoLinkPendingCredential() {
127-
guard let credential = pendingCredentialForLinking else { return }
128-
129-
Task {
130-
do {
131-
try await authService.linkAccounts(credentials: credential)
132-
// Successfully linked, clear the pending credential
133-
pendingCredentialForLinking = nil
134-
} catch let caughtError {
135-
// Show error - user is already signed in but linking failed
136-
reportError(caughtError)
137-
pendingCredentialForLinking = nil
138-
}
139-
}
140-
}
141-
14292
@ToolbarContentBuilder
14393
var toolbar: some ToolbarContent {
14494
ToolbarItem(placement: .topBarTrailing) {

0 commit comments

Comments
 (0)