From cf30d585794ce3de240c36b70e481af4c82e507b Mon Sep 17 00:00:00 2001 From: spacedandy-agents-simplex <342056592+spacedandy-agents-simplex@users.noreply.github.com> Date: Tue, 20 Oct 2026 23:46:51 +0000 Subject: [PATCH] ios: move preparing and opening a group out of the "Open group?" alert No change in behaviour: the next commit opens a directory result's group without the alert, through the same function. Run: 011-search-redesign, slice 3 (structural) --- .../Shared/Views/NewChat/NewChatView.swift | 57 ++++++++++++------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/apps/ios/Shared/Views/NewChat/NewChatView.swift b/apps/ios/Shared/Views/NewChat/NewChatView.swift index b558802d36..f2d31118bf 100644 --- a/apps/ios/Shared/Views/NewChat/NewChatView.swift +++ b/apps/ios/Shared/Views/NewChat/NewChatView.swift @@ -1199,25 +1199,14 @@ private func showPrepareGroupAlert( secondTitle: connectOtherButton, onCancel: { cleanup?() }, onConfirm: { - Task { - do { - let chat = try await apiPrepareGroup(connLink: connectionLink, directLink: groupShortLinkInfo?.direct ?? true, groupShortLinkData: groupShortLinkData, verifiedDomain: verifiedDomain) - await MainActor.run { - if let relays = groupShortLinkInfo?.groupRelays, !relays.isEmpty, - case let .group(gInfo, _) = chat.chatInfo { - ChatModel.shared.channelRelayHostnames[gInfo.groupId] = relays - } - ChatModel.shared.addChat(Chat(chat)) - openKnownChat(chat.id, dismiss: dismiss, cleanup: cleanup) - } - } catch let error { - logger.error("showPrepareGroupAlert apiPrepareGroup error: \(error.localizedDescription)") - showAlert(NSLocalizedString(isChannel ? "Error opening channel" : "Error opening group", comment: "alert title"), message: responseError(error)) - await MainActor.run { - cleanup?() - } - } - } + prepareAndOpenGroup( + connectionLink: connectionLink, + groupShortLinkInfo: groupShortLinkInfo, + groupShortLinkData: groupShortLinkData, + verifiedDomain: verifiedDomain, + dismiss: dismiss, + cleanup: cleanup + ) }, onSecond: connectOtherLink.map { link in { planAndConnect(link, theme: theme, dismiss: dismiss, cleanup: cleanup) } @@ -1225,6 +1214,36 @@ private func showPrepareGroupAlert( ) } +private func prepareAndOpenGroup( + connectionLink: CreatedConnLink, + groupShortLinkInfo: GroupShortLinkInfo?, + groupShortLinkData: GroupShortLinkData, + verifiedDomain: SimplexDomain?, + dismiss: Bool, + cleanup: (() -> Void)? +) { + let isChannel = !(groupShortLinkInfo?.direct ?? true) + Task { + do { + let chat = try await apiPrepareGroup(connLink: connectionLink, directLink: groupShortLinkInfo?.direct ?? true, groupShortLinkData: groupShortLinkData, verifiedDomain: verifiedDomain) + await MainActor.run { + if let relays = groupShortLinkInfo?.groupRelays, !relays.isEmpty, + case let .group(gInfo, _) = chat.chatInfo { + ChatModel.shared.channelRelayHostnames[gInfo.groupId] = relays + } + ChatModel.shared.addChat(Chat(chat)) + openKnownChat(chat.id, dismiss: dismiss, cleanup: cleanup) + } + } catch let error { + logger.error("prepareAndOpenGroup apiPrepareGroup error: \(error.localizedDescription)") + showAlert(NSLocalizedString(isChannel ? "Error opening channel" : "Error opening group", comment: "alert title"), message: responseError(error)) + await MainActor.run { + cleanup?() + } + } + } +} + private func showOpenKnownContactAlert( _ contact: Contact, theme: AppTheme,