| Index: ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
|
| diff --git a/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm b/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
|
| index aab29f26bea234c38a73d86df9869c9090777c81..01a8b22fab6b17a32ac0ce778676b29c3b6a5f06 100644
|
| --- a/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
|
| +++ b/ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.mm
|
| @@ -4,6 +4,9 @@
|
|
|
| #import "ios/chrome/browser/ui/payments/shipping_address_selection_coordinator.h"
|
|
|
| +#include <vector>
|
| +
|
| +#include "base/logging.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "components/autofill/core/browser/autofill_profile.h"
|
| #include "components/payments/core/strings_util.h"
|
| @@ -105,10 +108,7 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
|
| - (void)paymentRequestSelectorViewController:
|
| (PaymentRequestSelectorViewController*)controller
|
| didSelectItemAtIndex:(NSUInteger)index {
|
| - // Update the data source with the selection.
|
| - self.mediator.selectedItemIndex = index;
|
| -
|
| - CollectionViewItem<PaymentsIsSelectable>* paymentItem =
|
| + CollectionViewItem<PaymentsIsSelectable>* selectedItem =
|
| self.mediator.selectableItems[index];
|
|
|
| DCHECK(index < self.paymentRequest->billing_profiles().size());
|
| @@ -117,7 +117,9 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
|
|
|
| // Proceed with item selection only if the item has all required info, or
|
| // else bring up the address editor.
|
| - if (paymentItem.complete) {
|
| + if (selectedItem.complete) {
|
| + // Update the data source with the selection.
|
| + self.mediator.selectedItemIndex = index;
|
| [self delayedNotifyDelegateOfSelection:shippingProfile];
|
| } else {
|
| [self startAddressEditCoordinatorWithAddress:shippingProfile];
|
| @@ -156,6 +158,16 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
|
| // Update the data source with the new data.
|
| [self.mediator loadItems];
|
|
|
| + if (![self.viewController isEditing]) {
|
| + // Update the data source with the selection.
|
| + const std::vector<autofill::AutofillProfile*>& shippingProfiles =
|
| + self.paymentRequest->shipping_profiles();
|
| + const auto position =
|
| + std::find(shippingProfiles.begin(), shippingProfiles.end(), address);
|
| + DCHECK(position != shippingProfiles.end());
|
| + self.mediator.selectedItemIndex = position - shippingProfiles.begin();
|
| + }
|
| +
|
| [self.viewController loadModel];
|
| [self.viewController.collectionView reloadData];
|
|
|
| @@ -164,9 +176,9 @@ const int64_t kDelegateNotificationDelayInNanoSeconds = 0.2 * NSEC_PER_SEC;
|
|
|
| // Mark the item as complete meaning all required information has been
|
| // filled out.
|
| - CollectionViewItem<PaymentsIsSelectable>* paymentItem =
|
| + CollectionViewItem<PaymentsIsSelectable>* selectedItem =
|
| self.mediator.selectableItems[self.mediator.selectedItemIndex];
|
| - paymentItem.complete = YES;
|
| + selectedItem.complete = YES;
|
|
|
| if (![self.viewController isEditing]) {
|
| // Inform |self.delegate| that |address| has been selected.
|
|
|