damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 8c321e479b20d28f924cdedbfccce561bebbd2e3
parent 960c84d02e4be04fb78005b9eef5423c1b3b4176
Author: Swift Coder <scoder1747@gmail.com>
Date:   Wed, 20 Nov 2024 09:23:48 -0500

Fix Damus sharing issues

1. While sharing images/videos from Apple's Message app, the file will be treated as a Link with file-url. The if-else ordering will help to fix the issue.
2. While sharing image from Signal and Facebook app, the file being received is an UIImage and error is being sent. This PR fixes the issue.

Changelog-Fixed: Fix damus sharing issues
Signed-off-by: Swift Coder  <scoder1747@gmail.com>

Diffstat:
Mshare extension/ShareViewController.swift | 22++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/share extension/ShareViewController.swift b/share extension/ShareViewController.swift @@ -276,15 +276,7 @@ struct ShareExtensionView: View { // Iterate through all attachments to handle multiple images for itemProvider in extensionItem.attachments ?? [] { - if itemProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier) { - itemProvider.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil) { (item, error) in - if let url = item as? URL { - self.share_state = .loaded(ShareContent(title: title, content: .link(url))) - } else { - self.share_state = .failed(error: "Failed to load text content") - } - } - } else if itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier) { + if itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier) { itemProvider.loadItem(forTypeIdentifier: UTType.image.identifier, options: nil) { (item, error) in if let url = item as? URL { @@ -294,7 +286,9 @@ struct ShareExtensionView: View { unprocessedEnum: {.unprocessed_image($0)}, processedEnum: {.processed_image($0)}) - + } else if let image = item as? UIImage { + // process it directly if shared item is uiimage (example: image shared from Facebook, Signal apps) + chooseMedia(PreUploadedMedia.uiimage(image)) } else { self.share_state = .failed(error: "Failed to load image content") } @@ -313,6 +307,14 @@ struct ShareExtensionView: View { self.share_state = .failed(error: "Failed to load video content") } } + } else if itemProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier) { + itemProvider.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil) { (item, error) in + if let url = item as? URL { + self.share_state = .loaded(ShareContent(title: title, content: .link(url))) + } else { + self.share_state = .failed(error: "Failed to load text content") + } + } } else { share_state = .no_content }