mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Recognise dragged iOS screenshots as images instead of raw data
When dragging the floating screenshot preview into a room, iOS hands us a provider whose `suggestedName` is e.g. `Screenshot 2026-05-22 at 14.49.40`. `NSString.pathExtension` returns `"40"`, so the previous `!pathExtension.isEmpty` check treated the timestamp's trailing segment as a real extension. The file got written without `.jpg`/`.png`, and the `MediaUploadingPreprocessor` then fell back to `application/octet-stream` which is why screenshots showed up as a "data" tile.
This commit is contained in:
committed by
Stefan Ceriu
parent
ff4fe6c728
commit
2082e71888
@@ -196,8 +196,15 @@ extension NSItemProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private extension NSString {
|
||||
extension NSString {
|
||||
/// `NSString.pathExtension` returns the trailing dot-segment regardless of whether
|
||||
/// it's a real extension, and `UTType(filenameExtension:)` synthesises a `dyn.*`
|
||||
/// placeholder for unknown ones instead of returning nil — so check both.
|
||||
var hasPathExtension: Bool {
|
||||
!pathExtension.isEmpty
|
||||
guard !pathExtension.isEmpty,
|
||||
let type = UTType(filenameExtension: pathExtension) else {
|
||||
return false
|
||||
}
|
||||
return !type.isDynamic
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user