From a570d56ece166cf242f8b61eeab2302e7b0b0e9c Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Sat, 1 Aug 2026 16:20:04 +0000 Subject: [PATCH] ios: parameterise create-profile form's submit action CreateProfile hardcoded create-and-activate. Adds an optional onSubmit hook so the same form can create a profile for an invitation, which must not switch the active user until the prepared chat has been reassigned. Optional rather than required, unlike the Kotlin equivalent: it touches no existing call site, which matters more here because this cannot be compiled on the machine the change was written on. --- .../Views/Onboarding/CreateProfile.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/ios/Shared/Views/Onboarding/CreateProfile.swift b/apps/ios/Shared/Views/Onboarding/CreateProfile.swift index bd9530c4ee..cf26bf9835 100644 --- a/apps/ios/Shared/Views/Onboarding/CreateProfile.swift +++ b/apps/ios/Shared/Views/Onboarding/CreateProfile.swift @@ -29,6 +29,10 @@ enum UserProfileAlert: Identifiable { let MAX_BIO_LENGTH_BYTES = 160 struct CreateProfile: View { + // When set, replaces the default create-and-activate action, so the same form can be + // used to create a profile for an invitation (which must not switch the active user + // until the prepared chat has been reassigned). Errors are still shown by this view. + var onSubmit: ((_ displayName: String, _ shortDescr: String?, _ image: String?) async throws -> Void)? = nil @Environment(\.colorScheme) var colorScheme @Environment(\.dismiss) var dismiss @EnvironmentObject var theme: AppTheme @@ -162,6 +166,20 @@ struct CreateProfile: View { private func createProfile() { hideKeyboard() let shortDescr: String? = if profileBio.isEmpty { nil } else { profileBio } + if let onSubmit = onSubmit { + let name = displayName.trimmingCharacters(in: .whitespaces) + let image = profileImage + Task { + do { + try await onSubmit(name, shortDescr, image) + } catch let error { + await MainActor.run { + showCreateProfileAlert(showAlert: { alert = $0 }, error) + } + } + } + return + } let profile = Profile( displayName: displayName.trimmingCharacters(in: .whitespaces), fullName: "",