core: fix retrying connection via contact card (preset contacts) (#6104)

* core: fix retrying connection via contact card (preset contacts)

* ios

* kotlin

* banner
This commit is contained in:
spaced4ndy
2025-07-25 17:31:05 +01:00
committed by GitHub
parent 749f6adc00
commit e9a3eb8f10
9 changed files with 95 additions and 51 deletions
@@ -1778,7 +1778,7 @@ data class Contact(
}
val isContactCard: Boolean =
activeConn == null && profile.contactLink != null && active && preparedContact == null && contactRequestId == null
(activeConn == null || activeConn.connStatus == ConnStatus.Prepared) && profile.contactLink != null && active && preparedContact == null && contactRequestId == null
val contactConnIncognito =
activeConn?.customUserProfileId != null
@@ -794,33 +794,49 @@ fun askCurrentOrIncognitoProfileConnectContactViaAddress(
close: (() -> Unit)?,
openChat: Boolean
) {
@Composable
fun UseCurrentProfileButton() {
SectionItemView({
AlertManager.privacySensitive.hideAlert()
withBGApi {
val ok = connectContactViaAddress(chatModel, rhId, contact.contactId, incognito = false)
if (ok && openChat) {
close?.invoke()
openDirectChat(rhId, contact.contactId)
}
}
}) {
Text(generalGetString(MR.strings.connect_use_current_profile), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
}
}
@Composable
fun UseIncognitoProfileButton(text: String) {
SectionItemView({
AlertManager.privacySensitive.hideAlert()
withBGApi {
val ok = connectContactViaAddress(chatModel, rhId, contact.contactId, incognito = true)
if (ok && openChat) {
close?.invoke()
openDirectChat(rhId, contact.contactId)
}
}
}) {
Text(text, Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
}
}
AlertManager.privacySensitive.showAlertDialogButtonsColumn(
title = String.format(generalGetString(MR.strings.connect_with_contact_name_question), contact.chatViewName),
buttons = {
Column {
SectionItemView({
AlertManager.privacySensitive.hideAlert()
withBGApi {
close?.invoke()
val ok = connectContactViaAddress(chatModel, rhId, contact.contactId, incognito = false)
if (ok && openChat) {
openDirectChat(rhId, contact.contactId)
}
}
}) {
Text(generalGetString(MR.strings.connect_use_current_profile), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
}
SectionItemView({
AlertManager.privacySensitive.hideAlert()
withBGApi {
close?.invoke()
val ok = connectContactViaAddress(chatModel, rhId, contact.contactId, incognito = true)
if (ok && openChat) {
openDirectChat(rhId, contact.contactId)
}
}
}) {
Text(generalGetString(MR.strings.connect_use_new_incognito_profile), Modifier.fillMaxWidth(), textAlign = TextAlign.Center, color = MaterialTheme.colors.primary)
if (!contact.profileChangeProhibited) {
UseCurrentProfileButton()
UseIncognitoProfileButton(generalGetString(MR.strings.connect_use_new_incognito_profile))
} else if (!contact.contactConnIncognito) {
UseCurrentProfileButton()
} else {
UseIncognitoProfileButton(generalGetString(MR.strings.connect_use_incognito_profile))
}
SectionItemView({
AlertManager.privacySensitive.hideAlert()
@@ -104,6 +104,9 @@ fun ContactPreviewView(
modifier = Modifier
.size(21.dp)
)
if (chat.chatInfo.incognito) {
Spacer(Modifier.width(DEFAULT_SPACE_AFTER_ICON))
}
}
if (showDeletedChatIcon && chat.chatInfo.chatDeleted) {
@@ -9,6 +9,7 @@
<string name="connect_via_group_link">Join group?</string>
<string name="connect_use_current_profile">Use current profile</string>
<string name="connect_use_new_incognito_profile">Use new incognito profile</string>
<string name="connect_use_incognito_profile">Use incognito profile</string>
<string name="profile_will_be_sent_to_contact_sending_link">Your profile will be sent to the contact that you received this link from.</string>
<string name="you_will_join_group">You will connect to all group members.</string>
<string name="connect_via_link_verb">Connect</string>