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>
This commit is contained in:
committed by
Daniel D’Aquino
parent
960c84d02e
commit
8c321e479b
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user