Files
Greenlens/patches/expo-share-intent+5.1.1.patch
2026-05-18 15:59:46 +02:00

95 lines
5.2 KiB
Diff

diff --git a/node_modules/expo-share-intent/plugin/build/ios/ShareExtensionViewController.swift b/node_modules/expo-share-intent/plugin/build/ios/ShareExtensionViewController.swift
index 0911a9e..177b5bf 100644
--- a/node_modules/expo-share-intent/plugin/build/ios/ShareExtensionViewController.swift
+++ b/node_modules/expo-share-intent/plugin/build/ios/ShareExtensionViewController.swift
@@ -16,6 +16,7 @@ class ShareViewController: UIViewController {
var sharedMedia: [SharedMediaFile] = []
var sharedWebUrl: [WebUrl] = []
var sharedText: [String] = []
+ var expectedAttachmentCount: Int = 0
let imageContentType: String = UTType.image.identifier
let videoContentType: String = UTType.movie.identifier
let textContentType: String = UTType.text.identifier
@@ -40,7 +41,26 @@ class ShareViewController: UIViewController {
dismissWithError(message: "No content found")
return
}
- for (index, attachment) in (attachments).enumerated() {
+ let hasMediaAttachment = attachments.contains {
+ $0.hasItemConformingToTypeIdentifier(imageContentType)
+ || $0.hasItemConformingToTypeIdentifier(videoContentType)
+ }
+ let hasPreprocessingAttachment = attachments.contains {
+ $0.hasItemConformingToTypeIdentifier(propertyListType)
+ }
+ let handledAttachments = hasMediaAttachment
+ ? attachments.filter {
+ $0.hasItemConformingToTypeIdentifier(imageContentType)
+ || $0.hasItemConformingToTypeIdentifier(videoContentType)
+ }
+ : hasPreprocessingAttachment
+ ? attachments.filter {
+ $0.hasItemConformingToTypeIdentifier(propertyListType)
+ }
+ : attachments
+ self.expectedAttachmentCount = handledAttachments.count
+
+ for (index, attachment) in handledAttachments.enumerated() {
if attachment.hasItemConformingToTypeIdentifier(imageContentType) {
await handleImages(content: content, attachment: attachment, index: index)
} else if attachment.hasItemConformingToTypeIdentifier(videoContentType) {
@@ -103,7 +123,7 @@ class ShareViewController: UIViewController {
self.sharedText.append(item)
// If this is the last item, save sharedText in userDefaults and redirect to host app
- if index == (content.attachments?.count)! - 1 {
+ if index == self.expectedAttachmentCount - 1 {
let userDefaults = UserDefaults(suiteName: self.hostAppGroupIdentifier)
userDefaults?.set(self.sharedText, forKey: self.sharedKey)
userDefaults?.synchronize()
@@ -126,7 +146,7 @@ class ShareViewController: UIViewController {
self.sharedWebUrl.append(WebUrl(url: item.absoluteString, meta: ""))
// If this is the last item, save sharedText in userDefaults and redirect to host app
- if index == (content.attachments?.count)! - 1 {
+ if index == self.expectedAttachmentCount - 1 {
let userDefaults = UserDefaults(suiteName: self.hostAppGroupIdentifier)
userDefaults?.set(self.toData(data: self.sharedWebUrl), forKey: self.sharedKey)
userDefaults?.synchronize()
@@ -161,7 +181,7 @@ class ShareViewController: UIViewController {
self.sharedWebUrl.append(
WebUrl(url: results["baseURI"] as! String, meta: results["meta"] as! String))
// If this is the last item, save sharedText in userDefaults and redirect to host app
- if index == (content.attachments?.count)! - 1 {
+ if index == self.expectedAttachmentCount - 1 {
let userDefaults = UserDefaults(suiteName: self.hostAppGroupIdentifier)
userDefaults?.set(self.toData(data: self.sharedWebUrl), forKey: self.sharedKey)
userDefaults?.synchronize()
@@ -300,7 +320,7 @@ class ShareViewController: UIViewController {
}
// If this is the last item, save imagesData in userDefaults and redirect to host app
- if index == (content.attachments?.count)! - 1 {
+ if index == self.expectedAttachmentCount - 1 {
let userDefaults = UserDefaults(suiteName: self.hostAppGroupIdentifier)
userDefaults?.set(self.toData(data: self.sharedMedia), forKey: self.sharedKey)
userDefaults?.synchronize()
@@ -385,7 +405,7 @@ class ShareViewController: UIViewController {
}
// If this is the last item, save imagesData in userDefaults and redirect to host app
- if index == (content.attachments?.count)! - 1 {
+ if index == self.expectedAttachmentCount - 1 {
let userDefaults = UserDefaults(suiteName: self.hostAppGroupIdentifier)
userDefaults?.set(self.toData(data: self.sharedMedia), forKey: self.sharedKey)
userDefaults?.synchronize()
@@ -453,7 +473,7 @@ class ShareViewController: UIViewController {
type: .file))
}
- if index == (content.attachments?.count)! - 1 {
+ if index == self.expectedAttachmentCount - 1 {
let userDefaults = UserDefaults(suiteName: self.hostAppGroupIdentifier)
userDefaults?.set(self.toData(data: self.sharedMedia), forKey: self.sharedKey)
userDefaults?.synchronize()