Skip to content

Commit

Permalink
import vcards
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed May 29, 2024
1 parent aa8d002 commit b5870dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions deltachat-ios/Chat/ChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,9 @@ extension ChatViewController {

let alert = UIAlertController(title: String.localizedStringWithFormat(String.localized("ask_start_chat_with"), vcard.displayName), message: nil, preferredStyle: .safeActionSheet)
alert.addAction(UIAlertAction(title: String.localized("start_chat"), style: .default, handler: { _ in
if let ids = self.dcContext.importVcard(path: file) {

Check warning on line 2129 in deltachat-ios/Chat/ChatViewController.swift

View workflow job for this annotation

GitHub Actions / build

value 'ids' was defined but never used; consider replacing with boolean test
// TODO: open chat
}
}))
alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
present(alert, animated: true, completion: nil)
Expand Down
8 changes: 7 additions & 1 deletion deltachat-ios/DC/DcContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,13 @@ public class DcContext {
}

public func importVcard(path: String) -> [Int]? {
DcAccounts.shared.blockingCall(method: "import_vcard", params: [path as AnyObject])
if let data = DcAccounts.shared.blockingCall(method: "import_vcard", params: [id as AnyObject, path as AnyObject]) {
do {
return try JSONDecoder().decode(DcVcardImportResult.self, from: data).result
} catch {
logger.error("cannot import vcard: \(error)")
}
}
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions deltachat-ios/DC/DcVcard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ public struct DcVcardContact: Decodable {
struct DcVcardContactResult: Decodable {
let result: [DcVcardContact]
}

struct DcVcardImportResult: Decodable {
let result: [Int]
}

0 comments on commit b5870dc

Please sign in to comment.