Skip to content

Commit 03c5386

Browse files
committed
[Auth] Perform view dismiss on MainActor
1 parent 104a80a commit 03c5386

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

FirebaseAuth/Tests/SampleSwift/AuthenticationExample/CustomViews/MFALoginView.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ struct MFALoginView: View {
4545
accentColor: .white,
4646
backgroundColor: .orange
4747
) {
48-
// TODO(ncooke3): Does this task inherit a higher priority? What about the regular SwiftUI
49-
// button?
50-
Task(priority: .userInitiated, operation: startMfALogin)
48+
Task { await startMfALogin() }
5149
}
5250
.padding()
5351
} else {
@@ -59,7 +57,7 @@ struct MFALoginView: View {
5957
accentColor: .white,
6058
backgroundColor: .orange
6159
) {
62-
Task(priority: .userInitiated, operation: finishMfALogin)
60+
Task { await finishMfALogin() }
6361
}
6462
.padding()
6563
}
@@ -112,7 +110,10 @@ extension MFALoginView {
112110
let assertion = PhoneMultiFactorGenerator.assertion(with: credential)
113111
do {
114112
_ = try await resolver.resolveSignIn(with: assertion)
115-
dismiss()
113+
// MFA login was successful.
114+
await MainActor.run {
115+
dismiss()
116+
}
116117
} catch {
117118
print(error)
118119
}
@@ -128,7 +129,9 @@ extension MFALoginView {
128129
do {
129130
_ = try await resolver.resolveSignIn(with: assertion)
130131
// MFA login was successful.
131-
dismiss()
132+
await MainActor.run {
133+
dismiss()
134+
}
132135
} catch {
133136
// Wrong or expired OTP. Re-prompt the user.
134137
// TODO(ncooke3): Show error to user.

0 commit comments

Comments
 (0)