diff --git a/ShareExtension/ShareViewController.swift b/ShareExtension/ShareViewController.swift index a74ab0ae..022fdefd 100644 --- a/ShareExtension/ShareViewController.swift +++ b/ShareExtension/ShareViewController.swift @@ -79,7 +79,14 @@ class ShareViewController: UIViewController { var attachments: [DraftAttachment] = [] for itemProvider in inputItem.attachments ?? [] { - if let attached: NSURL = await getObject(from: itemProvider) { + // attachments have the highest priority, but only given this heuristic + // otherwise attachment decoding ends up being overzealous + let likelyAttachment = [UTType.image, .movie].contains(where: { itemProvider.hasItemConformingToTypeIdentifier($0.identifier) }) + + if likelyAttachment, + let attachment: DraftAttachment = await getObject(from: itemProvider) { + attachments.append(attachment) + } else if let attached: NSURL = await getObject(from: itemProvider) { if url == nil { url = attached as URL } @@ -87,8 +94,6 @@ class ShareViewController: UIViewController { if text.isEmpty { text = s as String } - } else if let attachment: DraftAttachment = await getObject(from: itemProvider) { - attachments.append(attachment) } }