diff --git a/deltachat-ios/Chat/ChatViewController.swift b/deltachat-ios/Chat/ChatViewController.swift index 1f73c0ea7..e36e6efa8 100644 --- a/deltachat-ios/Chat/ChatViewController.swift +++ b/deltachat-ios/Chat/ChatViewController.swift @@ -307,6 +307,10 @@ class ChatViewController: UITableViewController, UITableViewDropDelegate { if RelayHelper.shared.isForwarding() { if RelayHelper.shared.forwardIds != nil { askToForwardMessage() + } else if let vcardData = RelayHelper.shared.forwardVCardData, + let vcardURL = prepareVCardData(vcardData) { + stageVCard(url: vcardURL) + RelayHelper.shared.finishRelaying() } else if RelayHelper.shared.forwardFileData != nil || RelayHelper.shared.forwardText != nil { if let text = RelayHelper.shared.forwardText { messageInputBar.inputTextView.text = text @@ -2803,16 +2807,23 @@ extension ChatViewController: ChatDropInteractionDelegate { extension ChatViewController: SendContactViewControllerDelegate { func contactSelected(_ viewController: SendContactViewController, contactId: Int) { - guard let vcardData = dcContext.makeVCard(contactIds: [contactId]), - let fileName = FileHelper.saveData(data: vcardData, - name: UUID().uuidString, - suffix: "vcf", - directory: .cachesDirectory), - let vcardURL = URL(string: fileName) - else { return } + guard let vcardData = dcContext.makeVCard(contactIds: [contactId]), + let vcardURL = prepareVCardData(vcardData) else { return } stageVCard(url: vcardURL) } + + private func prepareVCardData(_ vcardData: Data) -> URL? { + guard let fileName = FileHelper.saveData(data: vcardData, + name: UUID().uuidString, + suffix: "vcf", + directory: .cachesDirectory), + let vcardURL = URL(string: fileName) else { + return nil + } + + return vcardURL + } } // MARK: - ReactionsOverviewViewControllerDelegate diff --git a/deltachat-ios/Controller/ContactDetailViewController.swift b/deltachat-ios/Controller/ContactDetailViewController.swift index 1dbab77e5..8968bec27 100644 --- a/deltachat-ios/Controller/ContactDetailViewController.swift +++ b/deltachat-ios/Controller/ContactDetailViewController.swift @@ -342,9 +342,10 @@ class ContactDetailViewController: UITableViewController { // MARK: - actions @objc private func shareContact() { - // compare to `forward`. - // 1. select chat you want to forward this contact to. - // 2. stage this very contacts vcard + guard let vcardData = viewModel.context.makeVCard(contactIds: [viewModel.contactId]) else { return } + + RelayHelper.shared.setForwardVCard(dialogTitle: String.localized("forward_to"), vcardData: vcardData) + navigationController?.popToRootViewController(animated: true) } @objc private func showCopyToClipboard() {