android, desktop: 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 4 (structural)
This commit is contained in:
spacedandy-agents-simplex committed 2026-10-21 02:29:47 +00:00
1 parent fca9f92702
commit 00fa486aae
1 file changed
+30 -18
@@ -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)