diff --git a/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift b/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift index 5da33af018..c46790c74d 100644 --- a/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift +++ b/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift @@ -281,12 +281,16 @@ struct ContextProfilePickerView: View { // resync to what the host actually did and report it. The failure is the // switch, not the creation, so it is not rethrown into the form's "error // creating profile" handler. - var switched = false + // let, not var: MainActor.run's body is @Sendable, and capturing a mutable + // local in one is diagnosed under strict concurrency. Assigned on both + // branches, so it is definitely initialised. + let switched: Bool do { try await changeActiveUserAsync_(newUser.userId, viewPwd: nil) switched = true } catch { logger.error("changeActiveUserAsync_ error: \(responseError(error))") + switched = false } await MainActor.run { // Only when the switch actually happened: the prepared chat then belongs