From ae13f1aa23d86e1b3bd3a5b9b357a571007eeff5 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Tue, 16 May 2023 15:03:41 +0400 Subject: [PATCH] mobile: connect to member via address (#2441) --- .../views/chat/group/GroupMemberInfoView.kt | 50 ++++++++++++-- .../app/src/main/res/values-cs/strings.xml | 2 +- .../app/src/main/res/values-de/strings.xml | 2 +- .../app/src/main/res/values-es/strings.xml | 2 +- .../app/src/main/res/values-fr/strings.xml | 2 +- .../app/src/main/res/values-it/strings.xml | 2 +- .../app/src/main/res/values-ja/strings.xml | 2 +- .../app/src/main/res/values-nl/strings.xml | 2 +- .../app/src/main/res/values-pl/strings.xml | 2 +- .../src/main/res/values-pt-rBR/strings.xml | 2 +- .../app/src/main/res/values-ru/strings.xml | 2 +- .../src/main/res/values-zh-rCN/strings.xml | 2 +- .../src/main/res/values-zh-rTW/strings.xml | 2 +- .../app/src/main/res/values/strings.xml | 2 +- apps/ios/Shared/Model/SimpleXAPI.swift | 69 +++++++++++-------- .../Chat/Group/GroupMemberInfoView.swift | 44 +++++++++++- .../Shared/Views/NewChat/NewChatButton.swift | 6 +- 17 files changed, 145 insertions(+), 50 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt index 572b46dff4..aa0fe05aba 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupMemberInfoView.kt @@ -6,6 +6,8 @@ import SectionDividerSpaced import SectionSpacer import SectionTextFooter import SectionView +import android.net.Uri +import android.util.Log import androidx.activity.compose.BackHandler import androidx.compose.foundation.* import androidx.compose.foundation.layout.* @@ -21,13 +23,13 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import chat.simplex.app.* import chat.simplex.app.R -import chat.simplex.app.SimplexApp import chat.simplex.app.model.* import chat.simplex.app.ui.theme.* import chat.simplex.app.views.chat.* import chat.simplex.app.views.helpers.* -import chat.simplex.app.views.newchat.QRCode +import chat.simplex.app.views.newchat.* import chat.simplex.app.views.usersettings.SettingsActionItem import kotlinx.datetime.Clock @@ -68,6 +70,15 @@ fun GroupMemberInfoView( } } }, + connectViaAddress = { connReqUri -> + val uri = Uri.parse(connReqUri) + withUriAction(uri) { linkType -> + withApi { + Log.d(TAG, "connectViaUri: connecting") + connectViaUri(chatModel, linkType, uri) + } + } + }, removeMember = { removeMemberDialog(groupInfo, member, chatModel, close) }, onRoleSelected = { if (it == newRole.value) return@GroupMemberInfoLayout @@ -147,11 +158,21 @@ fun GroupMemberInfoLayout( connectionCode: String?, getContactChat: (Long) -> Chat?, openDirectChat: (Long) -> Unit, + connectViaAddress: (String) -> Unit, removeMember: () -> Unit, onRoleSelected: (GroupMemberRole) -> Unit, switchMemberAddress: () -> Unit, verifyClicked: () -> Unit, ) { + fun knownDirectChat(contactId: Long): Chat? { + val chat = getContactChat(contactId) + return if (chat != null && chat.chatInfo is ChatInfo.Direct && chat.chatInfo.contact.directOrUsed) { + chat + } else { + null + } + } + Column( Modifier .fillMaxWidth() @@ -165,12 +186,12 @@ fun GroupMemberInfoLayout( } SectionSpacer() + val contactId = member.memberContactId + if (member.memberActive) { - val contactId = member.memberContactId if (contactId != null) { SectionView { - val chat = getContactChat(contactId) - if ((chat != null && chat.chatInfo is ChatInfo.Direct && chat.chatInfo.contact.directOrUsed) || groupInfo.fullGroupPreferences.directMessages.on) { + if (knownDirectChat(contactId) != null || groupInfo.fullGroupPreferences.directMessages.on) { OpenChatButton(onClick = { openDirectChat(contactId) }) } if (connectionCode != null) { @@ -186,6 +207,13 @@ fun GroupMemberInfoLayout( SectionView(stringResource(R.string.address_section_title).uppercase()) { QRCode(member.contactLink, Modifier.padding(horizontal = DEFAULT_PADDING, vertical = DEFAULT_PADDING_HALF).aspectRatio(1f)) ShareAddressButton { shareText(context, member.contactLink) } + if (contactId != null) { + if (knownDirectChat(contactId) == null && !groupInfo.fullGroupPreferences.directMessages.on) { + ConnectViaAddressButton(onClick = { connectViaAddress(member.contactLink) }) + } + } else { + ConnectViaAddressButton(onClick = { connectViaAddress(member.contactLink) }) + } SectionTextFooter(stringResource(R.string.you_can_share_this_address_with_your_contacts).format(member.displayName)) } SectionDividerSpaced() @@ -295,6 +323,17 @@ fun OpenChatButton(onClick: () -> Unit) { ) } +@Composable +fun ConnectViaAddressButton(onClick: () -> Unit) { + SettingsActionItem( + painterResource(R.drawable.ic_link), + stringResource(R.string.connect_button), + click = onClick, + textColor = MaterialTheme.colors.primary, + iconColor = MaterialTheme.colors.primary, + ) +} + @Composable private fun RoleSelectionRow( roles: List, @@ -354,6 +393,7 @@ fun PreviewGroupMemberInfoLayout() { connectionCode = "123", getContactChat = { Chat.sampleData }, openDirectChat = {}, + connectViaAddress = {}, removeMember = {}, onRoleSelected = {}, switchMemberAddress = {}, diff --git a/apps/android/app/src/main/res/values-cs/strings.xml b/apps/android/app/src/main/res/values-cs/strings.xml index 3e2e7f297d..77a666d555 100644 --- a/apps/android/app/src/main/res/values-cs/strings.xml +++ b/apps/android/app/src/main/res/values-cs/strings.xml @@ -128,7 +128,7 @@ Chyba odesílání zprávy Chyba přidávání členů Kontakt již existuje - Jste již připojeni k %1$s!. + Jste již připojeni k %1$s. Neplatný odkaz na spojení Chyba příjmu požadavku od kontaktu Chyba změny adresy diff --git a/apps/android/app/src/main/res/values-de/strings.xml b/apps/android/app/src/main/res/values-de/strings.xml index 1f3931369d..3fdd60bff5 100644 --- a/apps/android/app/src/main/res/values-de/strings.xml +++ b/apps/android/app/src/main/res/values-de/strings.xml @@ -63,7 +63,7 @@ Fehler beim Empfangen der Datei Fehler beim Erstellen der Adresse Kontakt ist bereits vorhanden - Sie sind bereits mit %1$s! verbunden. + Sie sind bereits mit %1$s verbunden. Ungültiger Verbindungslink Überprüfen Sie bitte, ob Sie den richtigen Link genutzt haben oder bitten Sie Ihren Kontakt darum, Ihnen nochmal einen Link zuzusenden. Verbindungsfehler (AUTH) diff --git a/apps/android/app/src/main/res/values-es/strings.xml b/apps/android/app/src/main/res/values-es/strings.xml index 119607814c..b1cf1c0e9b 100644 --- a/apps/android/app/src/main/res/values-es/strings.xml +++ b/apps/android/app/src/main/res/values-es/strings.xml @@ -867,7 +867,7 @@ Mensajes de voz Los mensajes de voz no están permitidos en este grupo. Comprobar la seguridad de la conexión - ¡Ya estás conectado a %1$s! . + ¡Ya estás conectado a %1$s. ¡Bienvenido! Tu perfil Chat será enviado \na tu contacto diff --git a/apps/android/app/src/main/res/values-fr/strings.xml b/apps/android/app/src/main/res/values-fr/strings.xml index 86651f457d..7fba34c2ab 100644 --- a/apps/android/app/src/main/res/values-fr/strings.xml +++ b/apps/android/app/src/main/res/values-fr/strings.xml @@ -60,7 +60,7 @@ Lien de connection invalide Délai de connexion Erreur lors de l\'envoi du message - Vous êtes déjà connecté à %1$s!. + Vous êtes déjà connecté à %1$s. Erreur de connexion (AUTH) A moins que votre contact ait supprimé la connexion ou que ce lien ait déjà été utilisé, il peut s\'agir d\'un bug - veuillez le signaler. \nPour vous connecter, veuillez demander à votre contact de créer un autre lien de connexion et vérifiez que vous disposez d\'une connexion réseau stable. diff --git a/apps/android/app/src/main/res/values-it/strings.xml b/apps/android/app/src/main/res/values-it/strings.xml index 0f7028b71d..fad3674d61 100644 --- a/apps/android/app/src/main/res/values-it/strings.xml +++ b/apps/android/app/src/main/res/values-it/strings.xml @@ -207,7 +207,7 @@ Descrizione via %1$s Aprire il link nel browser può ridurre la privacy e la sicurezza della connessione. I link SimpleX non fidati saranno in rosso. - Sei già connesso a %1$s!. + Sei già connesso a %1$s. A meno che il tuo contatto non abbia eliminato la connessione o che questo link non sia già stato usato, potrebbe essere un errore; per favore segnalalo. \nPer connetterti, chiedi al tuo contatto di creare un altro link di connessione e controlla di avere una connessione di rete stabile. Probabilmente l\'impronta del certificato nell\'indirizzo del server è sbagliata diff --git a/apps/android/app/src/main/res/values-ja/strings.xml b/apps/android/app/src/main/res/values-ja/strings.xml index 1a48ad9846..997b33dcce 100644 --- a/apps/android/app/src/main/res/values-ja/strings.xml +++ b/apps/android/app/src/main/res/values-ja/strings.xml @@ -927,7 +927,7 @@ SimpleXロゴ 音声メッセージを送るには、連絡相手からの音声メッセージを許可しなければなりません。 あなたの最新データベースを1つの端末にしか使わなければ、一部の連絡先からメッセージが届きかねます。 - 既に繋がってます: %1$s! + 既に繋がってます: %1$s シークレットモードのプロフィールでこのグループに参加しています。メインのプロフィールを守るために、招待することができません。 使い捨てリンクを送りました リンクを送ってくれた連絡先にあなたのプロフィールを送ります。 diff --git a/apps/android/app/src/main/res/values-nl/strings.xml b/apps/android/app/src/main/res/values-nl/strings.xml index 2df593634b..a831f5d2b3 100644 --- a/apps/android/app/src/main/res/values-nl/strings.xml +++ b/apps/android/app/src/main/res/values-nl/strings.xml @@ -638,7 +638,7 @@ verwijderd Uw chat profiel wordt verzonden naar de groepsleden Je hebt al een chat profiel met dezelfde weergave naam. Kies een andere naam. - U bent al verbonden met %1$s!. + U bent al verbonden met %1$s. Test mislukt bij stap %s. Veilige wachtrij De database werkt niet goed. Tik voor meer informatie diff --git a/apps/android/app/src/main/res/values-pl/strings.xml b/apps/android/app/src/main/res/values-pl/strings.xml index 4282fe111a..4fa413459a 100644 --- a/apps/android/app/src/main/res/values-pl/strings.xml +++ b/apps/android/app/src/main/res/values-pl/strings.xml @@ -1028,7 +1028,7 @@ %1$s CZŁONKÓW serwis SimpleX Chat %1$s chce się z Tobą połączyć przez - Jesteś już połączony z %1$s!. + Jesteś już połączony z %1$s. Możesz połączyć się z deweloperami SimpleX Chat aby zadać wszelkie pytania i otrzymywać aktualizacje. Możesz udostępnić link lub kod QR - każdy będzie mógł dołączyć do grupy. Nie stracisz członków grupy, jeśli później ją usuniesz. Musisz używać najnowszej wersji bazy danych czatu TYLKO na jednym urządzeniu, w przeciwnym razie możesz przestać otrzymywać wiadomości od niektórych kontaktów. diff --git a/apps/android/app/src/main/res/values-pt-rBR/strings.xml b/apps/android/app/src/main/res/values-pt-rBR/strings.xml index ed2a324f13..78a4685089 100644 --- a/apps/android/app/src/main/res/values-pt-rBR/strings.xml +++ b/apps/android/app/src/main/res/values-pt-rBR/strings.xml @@ -862,7 +862,7 @@ chamada de vídeo (não criptografada ponta-a-ponta) Parar chat\? Pelo navegador - Você já está conectado a%1$s!. + Você já está conectado a%1$s. O banco de dados não está funcionando corretamente. Toque para saber mais Aguardando imagem Mostrar código QR diff --git a/apps/android/app/src/main/res/values-ru/strings.xml b/apps/android/app/src/main/res/values-ru/strings.xml index 47996bfe7c..ef5725d0f0 100644 --- a/apps/android/app/src/main/res/values-ru/strings.xml +++ b/apps/android/app/src/main/res/values-ru/strings.xml @@ -63,7 +63,7 @@ Ошибка при получении файла Ошибка при создании адреса Существующий контакт - Вы уже соединены с контактом %1$s!. + Вы уже соединены с контактом %1$s. Ошибка в ссылке контакта Пожалуйста, проверьте, что Вы использовали правильную ссылку, или попросите Ваш контакт отправить Вам новую. Ошибка соединения (AUTH) diff --git a/apps/android/app/src/main/res/values-zh-rCN/strings.xml b/apps/android/app/src/main/res/values-zh-rCN/strings.xml index 13712bddd2..e43d301eeb 100644 --- a/apps/android/app/src/main/res/values-zh-rCN/strings.xml +++ b/apps/android/app/src/main/res/values-zh-rCN/strings.xml @@ -589,7 +589,7 @@ 待定来电 除非您的联系人已删除此连接或此链接已被使用,否则它可能是一个错误——请报告。 \n如果要连接,请让您的联系人创建另一个连接链接,并检查您的网络连接是否稳定。 - 您已经连接到 %1$s! + 您已经连接到 %1$s 您的聊天资料将被发送 \n给您的联系人 资料和服务器连接 diff --git a/apps/android/app/src/main/res/values-zh-rTW/strings.xml b/apps/android/app/src/main/res/values-zh-rTW/strings.xml index 6a43a34ac2..d62a710f6d 100644 --- a/apps/android/app/src/main/res/values-zh-rTW/strings.xml +++ b/apps/android/app/src/main/res/values-zh-rTW/strings.xml @@ -228,7 +228,7 @@ 透過瀏覽器 傳送訊息時出錯 聯絡人已存在 - 你已經連接到 %1$s! + 你已經連接到 %1$s 使用個人檔案(預設值)或使用連接(測試版)。 減少電量使用 更多改進即將推出! diff --git a/apps/android/app/src/main/res/values/strings.xml b/apps/android/app/src/main/res/values/strings.xml index ed8189604f..65be20b66a 100644 --- a/apps/android/app/src/main/res/values/strings.xml +++ b/apps/android/app/src/main/res/values/strings.xml @@ -90,7 +90,7 @@ Error receiving file Error creating address Contact already exists - You are already connected to %1$s!. + You are already connected to %1$s. Invalid connection link Please check that you used the correct link or ask your contact to send you another one. Connection error (AUTH) diff --git a/apps/ios/Shared/Model/SimpleXAPI.swift b/apps/ios/Shared/Model/SimpleXAPI.swift index 3e24d3a457..8dcdb8514a 100644 --- a/apps/ios/Shared/Model/SimpleXAPI.swift +++ b/apps/ios/Shared/Model/SimpleXAPI.swift @@ -314,7 +314,9 @@ func apiSendMessage(type: ChatType, id: Int64, file: String?, quotedItemId: Int6 chatModel.messageDelivery[cItem.id] = endTask return cItem } - if !networkErrorAlert(r) { + if let networkErrorAlert = networkErrorAlert(r) { + AlertManager.shared.showAlert(networkErrorAlert) + } else { sendMessageErrorAlert(r) } endTask() @@ -516,59 +518,71 @@ func apiAddContact() async -> String? { } let r = await chatSendCmd(.apiAddContact(userId: userId), bgTask: false) if case let .invitation(_, connReqInvitation) = r { return connReqInvitation } - connectionErrorAlert(r) + AlertManager.shared.showAlert(connectionErrorAlert(r)) return nil } func apiConnect(connReq: String) async -> ConnReqType? { + let (connReqType, alert) = await apiConnect_(connReq: connReq) + if let alert = alert { + AlertManager.shared.showAlert(alert) + return nil + } else { + return connReqType + } +} + +func apiConnect_(connReq: String) async -> (ConnReqType?, Alert?) { guard let userId = ChatModel.shared.currentUser?.userId else { logger.error("apiConnect: no current user") - return nil + return (nil, nil) } let r = await chatSendCmd(.apiConnect(userId: userId, connReq: connReq)) let am = AlertManager.shared switch r { - case .sentConfirmation: return .invitation - case .sentInvitation: return .contact + case .sentConfirmation: return (.invitation, nil) + case .sentInvitation: return (.contact, nil) case let .contactAlreadyExists(_, contact): let m = ChatModel.shared if let c = m.getContactChat(contact.contactId) { await MainActor.run { m.chatId = c.id } } - am.showAlertMsg( + let alert = mkAlert( title: "Contact already exists", message: "You are already connected to \(contact.displayName)." ) - return nil + return (nil, alert) case .chatCmdError(_, .error(.invalidConnReq)): - am.showAlertMsg( + let alert = mkAlert( title: "Invalid connection link", message: "Please check that you used the correct link or ask your contact to send you another one." ) - return nil + return (nil, alert) case .chatCmdError(_, .errorAgent(.SMP(.AUTH))): - am.showAlertMsg( + let alert = mkAlert( title: "Connection error (AUTH)", message: "Unless your contact deleted the connection or this link was already used, it might be a bug - please report it.\nTo connect, please ask your contact to create another connection link and check that you have a stable network connection." ) - return nil + return (nil, alert) case let .chatCmdError(_, .errorAgent(.INTERNAL(internalErr))): if internalErr == "SEUniqueID" { - am.showAlertMsg( + let alert = mkAlert( title: "Already connected?", message: "It seems like you are already connected via this link. If it is not the case, there was an error (\(responseError(r)))." ) - return nil + return (nil, alert) } default: () } - connectionErrorAlert(r) - return nil + let alert = connectionErrorAlert(r) + return (nil, alert) } -private func connectionErrorAlert(_ r: ChatResponse) { - if !networkErrorAlert(r) { - AlertManager.shared.showAlertMsg( +private func connectionErrorAlert(_ r: ChatResponse) -> Alert { + if let networkErrorAlert = networkErrorAlert(r) { + return networkErrorAlert + } else { + return mkAlert( title: "Connection error", message: "Error: \(String(describing: r))" ) @@ -710,7 +724,9 @@ func apiAcceptContactRequest(contactReqId: Int64) async -> Contact? { title: "Connection error (AUTH)", message: "Sender may have deleted the connection request." ) - } else if !networkErrorAlert(r) { + } else if let networkErrorAlert = networkErrorAlert(r) { + am.showAlert(networkErrorAlert) + } else { logger.error("apiAcceptContactRequest error: \(String(describing: r))") am.showAlertMsg( title: "Error accepting contact request", @@ -749,7 +765,9 @@ func apiReceiveFile(fileId: Int64, inline: Bool? = nil) async -> AChatItem? { title: "Cannot receive file", message: "Sender cancelled file transfer." ) - } else if !networkErrorAlert(r) { + } else if let networkErrorAlert = networkErrorAlert(r) { + am.showAlert(networkErrorAlert) + } else { logger.error("apiReceiveFile error: \(String(describing: r))") switch r { case .chatCmdError(_, .error(.fileAlreadyReceiving)): @@ -782,23 +800,20 @@ func apiCancelFile(fileId: Int64) async -> AChatItem? { } } -func networkErrorAlert(_ r: ChatResponse) -> Bool { - let am = AlertManager.shared +func networkErrorAlert(_ r: ChatResponse) -> Alert? { switch r { case let .chatCmdError(_, .errorAgent(.BROKER(addr, .TIMEOUT))): - am.showAlertMsg( + return mkAlert( title: "Connection timeout", message: "Please check your network connection with \(serverHostname(addr)) and try again." ) - return true case let .chatCmdError(_, .errorAgent(.BROKER(addr, .NETWORK))): - am.showAlertMsg( + return mkAlert( title: "Connection error", message: "Please check your network connection with \(serverHostname(addr)) and try again." ) - return true default: - return false + return nil } } diff --git a/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift b/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift index dd13741141..6decf50b35 100644 --- a/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift +++ b/apps/ios/Shared/Views/Chat/Group/GroupMemberInfoView.swift @@ -25,14 +25,18 @@ struct GroupMemberInfoView: View { case removeMemberAlert(mem: GroupMember) case changeMemberRoleAlert(mem: GroupMember, role: GroupMemberRole) case switchAddressAlert + case connRequestSentAlert(type: ConnReqType) case error(title: LocalizedStringKey, error: LocalizedStringKey) + case other(alert: Alert) var id: String { switch self { case .removeMemberAlert: return "removeMemberAlert" case let .changeMemberRoleAlert(_, role): return "changeMemberRoleAlert \(role.rawValue)" case .switchAddressAlert: return "switchAddressAlert" + case .connRequestSentAlert: return "connRequestSentAlert" case let .error(title, _): return "error \(title)" + case let .other(alert): return "other \(alert)" } } } @@ -45,6 +49,15 @@ struct GroupMemberInfoView: View { } } + private func knownDirectChat(_ contactId: Int64) -> Chat? { + if let chat = chatModel.getContactChat(contactId), + chat.chatInfo.contact?.directOrUsed == true { + return chat + } else { + return nil + } + } + private func groupMemberInfoView() -> some View { VStack { List { @@ -54,8 +67,7 @@ struct GroupMemberInfoView: View { if member.memberActive { Section { if let contactId = member.memberContactId { - if let chat = chatModel.getContactChat(contactId), - chat.chatInfo.contact?.directOrUsed ?? false { + if let chat = knownDirectChat(contactId) { knownDirectChatButton(chat) } else if groupInfo.fullGroupPreferences.directMessages.on { newDirectChatButton(contactId) @@ -73,6 +85,13 @@ struct GroupMemberInfoView: View { } label: { Label("Share address", systemImage: "square.and.arrow.up") } + if let contactId = member.memberContactId { + if knownDirectChat(contactId) == nil && !groupInfo.fullGroupPreferences.directMessages.on { + connectViaAddressButton(contactLink) + } + } else { + connectViaAddressButton(contactLink) + } } header: { Text("Address") } footer: { @@ -150,7 +169,28 @@ struct GroupMemberInfoView: View { case let .removeMemberAlert(mem): return removeMemberAlert(mem) case let .changeMemberRoleAlert(mem, _): return changeMemberRoleAlert(mem) case .switchAddressAlert: return switchAddressAlert(switchMemberAddress) + case let .connRequestSentAlert(type): return connReqSentAlert(type) case let .error(title, error): return Alert(title: Text(title), message: Text(error)) + case let .other(alert): return alert + } + } + } + + func connectViaAddressButton(_ contactLink: String) -> some View { + Button { + connectViaAddress(contactLink) + } label: { + Label("Connect", systemImage: "link") + } + } + + func connectViaAddress(_ contactLink: String) { + Task { + let (connReqType, connectAlert) = await apiConnect_(connReq: contactLink) + if let connReqType = connReqType { + alert = .connRequestSentAlert(type: connReqType) + } else if let connectAlert = connectAlert { + alert = .other(alert: connectAlert) } } } diff --git a/apps/ios/Shared/Views/NewChat/NewChatButton.swift b/apps/ios/Shared/Views/NewChat/NewChatButton.swift index bdf8f9b02e..3486ab6ef8 100644 --- a/apps/ios/Shared/Views/NewChat/NewChatButton.swift +++ b/apps/ios/Shared/Views/NewChat/NewChatButton.swift @@ -68,7 +68,7 @@ func connectViaLink(_ connectionLink: String, _ dismiss: DismissAction? = nil) { if let connReqType = await apiConnect(connReq: connectionLink) { DispatchQueue.main.async { dismiss?() - connectionReqSentAlert(connReqType) + AlertManager.shared.showAlert(connReqSentAlert(connReqType)) } } else { DispatchQueue.main.async { @@ -111,8 +111,8 @@ func groupLinkAlert(_ connectionLink: String) -> Alert { ) } -func connectionReqSentAlert(_ type: ConnReqType) { - AlertManager.shared.showAlertMsg( +func connReqSentAlert(_ type: ConnReqType) -> Alert { + return mkAlert( title: "Connection request sent!", message: type == .contact ? "You will be connected when your connection request is accepted, please wait or check later!"