Fix share extension type priority
This commit is contained in:
parent
b735e08427
commit
d2750ccc4d
|
@ -148,28 +148,30 @@ public extension CompositionViewModel {
|
||||||
parentViewModel: NewStatusViewModel) {
|
parentViewModel: NewStatusViewModel) {
|
||||||
self.init(eventsSubject: eventsSubject)
|
self.init(eventsSubject: eventsSubject)
|
||||||
|
|
||||||
guard let inputItem = extensionContext.inputItems.first as? NSExtensionItem,
|
guard let inputItem = extensionContext.inputItems.first as? NSExtensionItem else { return }
|
||||||
let itemProvider = inputItem.attachments?.first
|
|
||||||
else { return }
|
|
||||||
|
|
||||||
if itemProvider.hasItemConformingToTypeIdentifier(UTType.plainText.identifier) {
|
if let urlItemProvider = inputItem.attachments?.first(where: {
|
||||||
itemProvider.loadItem(forTypeIdentifier: UTType.plainText.identifier, options: nil) { result, _ in
|
$0.hasItemConformingToTypeIdentifier(UTType.url.identifier)
|
||||||
guard let text = result as? String else { return }
|
}) {
|
||||||
|
urlItemProvider.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil) { result, _ in
|
||||||
self.text = text
|
|
||||||
}
|
|
||||||
} else if itemProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier) {
|
|
||||||
itemProvider.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil) { result, _ in
|
|
||||||
guard let url = result as? URL else { return }
|
guard let url = result as? URL else { return }
|
||||||
|
|
||||||
if let contentText = inputItem.attributedContentText?.string {
|
if let contentText = inputItem.attributedContentText?.string, !contentText.isEmpty {
|
||||||
self.text.append(contentText)
|
self.text.append(contentText)
|
||||||
self.text.append("\n\n")
|
self.text.append("\n\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
self.text.append(url.absoluteString)
|
self.text.append(url.absoluteString)
|
||||||
}
|
}
|
||||||
} else {
|
} else if let plainTextItemProvider = inputItem.attachments?.first(where: {
|
||||||
|
$0.hasItemConformingToTypeIdentifier(UTType.plainText.identifier)
|
||||||
|
}) {
|
||||||
|
plainTextItemProvider.loadItem(forTypeIdentifier: UTType.plainText.identifier, options: nil) { result, _ in
|
||||||
|
guard let text = result as? String else { return }
|
||||||
|
|
||||||
|
self.text = text
|
||||||
|
}
|
||||||
|
} else if let itemProvider = inputItem.attachments?.first {
|
||||||
attach(itemProvider: itemProvider, parentViewModel: parentViewModel)
|
attach(itemProvider: itemProvider, parentViewModel: parentViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue