Skip to content

Commit 23c62b9

Browse files
authored
Merge pull request #5672 from woocommerce/issue/5569-crash-product-images
Product images: fix crash when tapping on an image while another image is pending upload
2 parents 5815ab7 + 46ac0fe commit 23c62b9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [***] In-Person Payments: Now you can collect Simple Payments on the go. [https://github.com/woocommerce/woocommerce-ios/pull/5635]
1010
- [*] Products: After generating a new variation for a variable product, you are now taken directly to edit the new variation. [https://github.com/woocommerce/woocommerce-ios/pull/5649]
1111
- [*] Dashboard: the visitor count in the Today tab is now shown when Jetpack site stats are enabled.
12+
- [*] Add/Edit Product Images: tapping on the last `n` images while `n` images are pending upload does not crash the app anymore. [https://github.com/woocommerce/woocommerce-ios/pull/5672]
1213

1314
8.2
1415
-----

WooCommerce/Classes/ViewRelated/Products/Media/ProductImagesCollectionViewController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,14 @@ extension ProductImagesCollectionViewController {
123123
return
124124
}
125125

126+
let selectedImageIndex: Int = {
127+
// In case of any pending images, deduct the number of pending images from the index.
128+
let imageStatusIndex = indexPath.row
129+
let numberOfPendingImages = productImageStatuses.count - productImageStatuses.images.count
130+
return imageStatusIndex - numberOfPendingImages
131+
}()
126132
let productImagesGalleryViewController = ProductImagesGalleryViewController(images: productImageStatuses.images,
127-
selectedIndex: indexPath.row,
133+
selectedIndex: selectedImageIndex,
128134
isDeletionEnabled: isDeletionEnabled,
129135
productUIImageLoader: productUIImageLoader) { [weak self] (productImage) in
130136
self?.onDeletion(productImage)

0 commit comments

Comments
 (0)