Skip to content

Commit d4c7e9f

Browse files
committed
Deduct number of pending images from selected index in image gallery.
1 parent 5815ab7 commit d4c7e9f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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)