Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(camera): now we honor users selection order #1951

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions camera/ios/Sources/CameraPlugin/CameraPlugin.swift
Expand Up @@ -261,9 +261,12 @@ extension CameraPlugin: PHPickerViewControllerDelegate {
return
}
if multiple {
var images: [ProcessedImage] = []
var images: [ProcessedImage?] = Array(repeating: nil, count: results.count)
var processedCount = 0
for img in results {

for index in results.indices {
let img = results[index]

guard img.itemProvider.canLoadObject(ofClass: UIImage.self) else {
self.call?.reject("Error loading image")
return
Expand All @@ -276,11 +279,11 @@ extension CameraPlugin: PHPickerViewControllerDelegate {
asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
}
if let processedImage = self?.processedImage(from: image, with: asset?.imageData) {
images.append(processedImage)
images[index] = processedImage
}
processedCount += 1
if processedCount == results.count {
self?.returnImages(images)
self?.returnImages(images.compactMap({ $0 }))
}
} else {
self?.call?.reject("Error loading image")
Expand Down