fix(account): defer operation-error dismissal until the alert update ends
This commit is contained in:
@@ -97,9 +97,7 @@ struct MainAppRoot: View {
|
|||||||
AppL10n.string("account.error.title"),
|
AppL10n.string("account.error.title"),
|
||||||
isPresented: accountOperationErrorBinding
|
isPresented: accountOperationErrorBinding
|
||||||
) {
|
) {
|
||||||
Button(AppL10n.string("common.done")) {
|
Button(AppL10n.string("common.done")) {}
|
||||||
accountSession.dismissOperationError()
|
|
||||||
}
|
|
||||||
} message: {
|
} message: {
|
||||||
if let key = accountSession.operationErrorKey {
|
if let key = accountSession.operationErrorKey {
|
||||||
Text(AppL10n.string(key))
|
Text(AppL10n.string(key))
|
||||||
@@ -326,7 +324,11 @@ struct MainAppRoot: View {
|
|||||||
get: { accountSession.operationErrorKey != nil },
|
get: { accountSession.operationErrorKey != nil },
|
||||||
set: { isPresented in
|
set: { isPresented in
|
||||||
if !isPresented {
|
if !isPresented {
|
||||||
accountSession.dismissOperationError()
|
// SwiftUI writes this binding while updating the alert.
|
||||||
|
// Defer ObservableObject mutations until that update ends.
|
||||||
|
Task { @MainActor in
|
||||||
|
accountSession.dismissOperationError()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user