mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Fallback to the first type with a valid extension when sharing media and no supported content types can be found
This commit is contained in:
@@ -125,6 +125,18 @@ extension NSItemProvider {
|
||||
let supportedContentTypes = registeredContentTypes
|
||||
.filter { isMimeTypeSupported($0.preferredMIMEType) || isIdentifierSupported($0.identifier) }
|
||||
|
||||
// If we can't find any supported types try to fallback to the first with
|
||||
// a valid extension. Return nil otherwise.
|
||||
guard !supportedContentTypes.isEmpty else {
|
||||
for type in registeredContentTypes {
|
||||
if let fileExtension = type.preferredFilenameExtension {
|
||||
return .init(type: type, fileExtension: fileExtension)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Have .jpeg take priority over .heic
|
||||
if supportedContentTypes.contains(.jpeg) {
|
||||
guard let fileExtension = preferredFileExtension(for: .jpeg) else {
|
||||
|
||||
Reference in New Issue
Block a user