Index: ios/chrome/browser/payments/shipping_address_selection_view_controller.mm |
diff --git a/ios/chrome/browser/payments/shipping_address_selection_view_controller.mm b/ios/chrome/browser/payments/shipping_address_selection_view_controller.mm |
index 8e16f0329bcaaabfdc455bc8b579a29ba93ff203..91a7040b5db2ad9e2a64dbbce4920d1fc809f438 100644 |
--- a/ios/chrome/browser/payments/shipping_address_selection_view_controller.mm |
+++ b/ios/chrome/browser/payments/shipping_address_selection_view_controller.mm |
@@ -140,24 +140,29 @@ typedef NS_ENUM(NSInteger, ItemType) { |
CollectionViewModel* model = self.collectionViewModel; |
- NSInteger itemType = |
- [self.collectionViewModel itemTypeForIndexPath:indexPath]; |
- CollectionViewItem* item = |
- [self.collectionViewModel itemAtIndexPath:indexPath]; |
- |
+ NSInteger itemType = [model itemTypeForIndexPath:indexPath]; |
if (itemType == ItemTypeShippingAddress) { |
- NSInteger index = [model indexInItemTypeForIndexPath:indexPath]; |
- DCHECK(index < (NSInteger)_shippingAddresses.size()); |
- self.selectedShippingAddress = _shippingAddresses[index]; |
- |
- ShippingAddressItem* shippingAddressItem = |
- base::mac::ObjCCastStrict<ShippingAddressItem>(item); |
- shippingAddressItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; |
- _selectedItem.accessoryType = MDCCollectionViewCellAccessoryNone; |
- [self reconfigureCellsForItems:@[ _selectedItem, shippingAddressItem ] |
- inSectionWithIdentifier:SectionIdentifierShippingAddress]; |
- _selectedItem = shippingAddressItem; |
- |
+ NSIndexPath* currentlySeletedIndexPath = [self.collectionViewModel |
Justin Donnelly
2017/01/10 17:11:53
s/Seleted/Selected/
Moe
2017/01/12 00:06:18
Done.
|
+ indexPathForItem:_selectedItem |
+ inSectionWithIdentifier:SectionIdentifierShippingAddress]; |
+ if (currentlySeletedIndexPath != indexPath) { |
+ // Update the cells. |
+ CollectionViewItem* item = [model itemAtIndexPath:indexPath]; |
+ ShippingAddressItem* newlySelectedItem = |
+ base::mac::ObjCCastStrict<ShippingAddressItem>(item); |
+ newlySelectedItem.accessoryType = MDCCollectionViewCellAccessoryCheckmark; |
+ |
+ _selectedItem.accessoryType = MDCCollectionViewCellAccessoryNone; |
+ |
+ [self reconfigureCellsForItems:@[ _selectedItem, newlySelectedItem ] |
+ inSectionWithIdentifier:SectionIdentifierShippingAddress]; |
+ |
+ // Update the selected shipping address and its respective item. |
+ NSInteger index = [model indexInItemTypeForIndexPath:indexPath]; |
+ DCHECK(index < (NSInteger)_shippingAddresses.size()); |
+ self.selectedShippingAddress = _shippingAddresses[index]; |
+ _selectedItem = newlySelectedItem; |
+ } |
[_delegate |
shippingAddressSelectionViewController:self |
selectedShippingAddress:self.selectedShippingAddress]; |