diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/ConnectPlan.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/ConnectPlan.kt index 8b145ef206..e55834c8ac 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/ConnectPlan.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/ConnectPlan.kt @@ -776,24 +776,7 @@ fun showPrepareGroupAlert( confirmText = generalGetString(if (isChannel) MR.strings.connect_plan_open_channel else MR.strings.connect_plan_open_group), onConfirm = { AlertManager.privacySensitive.hideAlert() - withBGApi { - val directLink = groupShortLinkInfo?.direct ?: true - val chat = chatModel.controller.apiPrepareGroup(rhId, connectionLink, directLink = directLink, groupShortLinkData, planSimplexName?.nameDomain) - if (chat != null) { - withContext(Dispatchers.Main) { - val relays = groupShortLinkInfo?.groupRelays - if (!relays.isNullOrEmpty()) { - val chatInfo = chat.chatInfo - if (chatInfo is ChatInfo.Group) { - chatModel.channelRelayHostnames[chatInfo.groupInfo.groupId] = relays - } - } - ChatController.chatModel.chatsContext.addChat(chat) - openChat_(chatModel, rhId, close, chat) - } - } - cleanup?.invoke() - } + prepareAndOpenGroup(rhId, connectionLink, groupShortLinkInfo, groupShortLinkData, planSimplexName?.nameDomain, close, cleanup) }, connectOtherButton = connectOtherButton, onConnectOther = connectOtherLink?.let { link -> { withBGApi { planAndConnect(rhId, link, close = close, cleanup = cleanup) } } }, @@ -803,6 +786,35 @@ fun showPrepareGroupAlert( ) } +private fun prepareAndOpenGroup( + rhId: Long?, + connectionLink: CreatedConnLink, + groupShortLinkInfo: GroupShortLinkInfo?, + groupShortLinkData: GroupShortLinkData, + verifiedDomain: SimplexDomain?, + close: (() -> Unit)?, + cleanup: (() -> Unit)? +) { + withBGApi { + val directLink = groupShortLinkInfo?.direct ?: true + val chat = chatModel.controller.apiPrepareGroup(rhId, connectionLink, directLink = directLink, groupShortLinkData, verifiedDomain) + if (chat != null) { + withContext(Dispatchers.Main) { + val relays = groupShortLinkInfo?.groupRelays + if (!relays.isNullOrEmpty()) { + val chatInfo = chat.chatInfo + if (chatInfo is ChatInfo.Group) { + chatModel.channelRelayHostnames[chatInfo.groupInfo.groupId] = relays + } + } + ChatController.chatModel.chatsContext.addChat(chat) + openChat_(chatModel, rhId, close, chat) + } + } + cleanup?.invoke() + } +} + fun ownerVerificationMessage(ov: OwnerVerification?): String? = when (ov) { is OwnerVerification.Verified -> generalGetString(MR.strings.owner_verification_passed) is OwnerVerification.Failed -> String.format(generalGetString(MR.strings.owner_verification_failed), ov.reason)