Skip to content

Commit

Permalink
share files generated by webxdc (#2606)
Browse files Browse the repository at this point in the history
* add option to share files generated by webxdc

* display name correctly in the share dialog

use temp. directory,
this somehow displays the name correctly in the share dialog
(we use the same for sharing log)

* update CHANGELOG
  • Loading branch information
r10s authored Feb 13, 2025
1 parent 57b1e79 commit 328e6e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased
2025-02

- Share files generated by webxdc apps directly (#2606)
- Tweak menu order (#2604)
- Fix: Preserve filenames on sharing (#2605)

Expand Down
13 changes: 13 additions & 0 deletions deltachat-ios/Controller/WebxdcViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,19 @@ extension WebxdcViewController: WKScriptMessageHandler {
rootController.popToRootViewController(animated: false)
}
}))

if let name = dict["name"] as? String {
alert.addAction(UIAlertAction(title: String.localized("menu_share"), style: .default, handler: { [weak self] _ in
guard let self else { return }
if let base64 = dict["base64"] as? String, let data = Data(base64Encoded: base64), let sourceItem = navigationItem.rightBarButtonItem {
let fileURL = FileManager.default.temporaryDirectory.appendingPathComponent(name)
try? FileManager.default.removeItem(at: fileURL)
try? data.write(to: fileURL)
Utils.share(url: fileURL, parentViewController: self, sourceItem: sourceItem)
}
}))
}

alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
}
Expand Down

0 comments on commit 328e6e7

Please sign in to comment.