mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Don't report an empty media selection as a successful pick
Both PhotoLibraryPicker and DocumentPicker reported failures via .error but still emitted .selectedMediaAtURLs([]) when every selected item failed to load or export (e.g. an iCloud photo that isn't downloaded, or a document that fails the security-scoped temp copy) - an empty "success" that consumers had to defend against. Skip that emission in both, and report .error for PhotoLibraryPicker's previously silent missing-content-type case so the user gets feedback.
This commit is contained in:
@@ -90,6 +90,11 @@ struct DocumentPicker: UIViewControllerRepresentable {
|
||||
}
|
||||
}
|
||||
|
||||
guard !selectedURLs.isEmpty else {
|
||||
// Every picked document failed to copy; each failure was already surfaced via .error.
|
||||
return
|
||||
}
|
||||
|
||||
documentPicker.callback(.selectedMediaAtURLs(selectedURLs))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,11 @@ struct PhotoLibraryPicker: UIViewControllerRepresentable {
|
||||
return selectedURLs.compactMap { $0 }
|
||||
}
|
||||
|
||||
guard !selectedURLs.isEmpty else {
|
||||
// Every selected item failed to load; each failure was already surfaced via .error.
|
||||
return
|
||||
}
|
||||
|
||||
photoLibraryPicker.callback(.selectedMediaAtURLs(selectedURLs))
|
||||
}
|
||||
}
|
||||
@@ -114,6 +119,9 @@ struct PhotoLibraryPicker: UIViewControllerRepresentable {
|
||||
let provider = result.itemProvider
|
||||
|
||||
guard let contentType = provider.preferredContentType else {
|
||||
Task { @MainActor in
|
||||
photoLibraryPicker.callback(.error(.failedLoadingFileRepresentation(nil)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user