Skip to content

Commit

Permalink
Forward contact (#2273)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Aug 29, 2024
1 parent e83f716 commit c886a19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
25 changes: 18 additions & 7 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions deltachat-ios/Controller/ContactDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c886a19

Please sign in to comment.