| Index: ios/chrome/browser/ui/collection_view/collection_view_model.mm
|
| diff --git a/ios/chrome/browser/ui/collection_view/collection_view_model.mm b/ios/chrome/browser/ui/collection_view/collection_view_model.mm
|
| index 0866b37bdafde7636ef71ab9c88f608417224f14..5825f6e1103ebb33669fbf34ecd3c6c50bbd7d53 100644
|
| --- a/ios/chrome/browser/ui/collection_view/collection_view_model.mm
|
| +++ b/ios/chrome/browser/ui/collection_view/collection_view_model.mm
|
| @@ -256,15 +256,23 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems;
|
| indexOfObject:item] != NSNotFound;
|
| }
|
|
|
| -- (NSIndexPath*)indexPathForItem:(CollectionViewItem*)item
|
| - inSectionWithIdentifier:(NSInteger)sectionIdentifier {
|
| - NSArray* itemsInSection =
|
| - [self itemsInSectionWithIdentifier:sectionIdentifier];
|
| +- (BOOL)hasItem:(CollectionViewItem*)item {
|
| + for (NSNumber* section in _sectionIdentifiers) {
|
| + if ([self hasItem:item inSectionWithIdentifier:[section integerValue]])
|
| + return YES;
|
| + }
|
| + return NO;
|
| +}
|
|
|
| - NSInteger section = [self sectionForSectionIdentifier:sectionIdentifier];
|
| - NSInteger itemIndex = [itemsInSection indexOfObject:item];
|
| - DCHECK_NE(NSNotFound, itemIndex);
|
| - return [NSIndexPath indexPathForItem:itemIndex inSection:section];
|
| +- (NSIndexPath*)indexPathForItem:(CollectionViewItem*)item {
|
| + for (NSUInteger section = 0; section < _sections.count; section++) {
|
| + NSInteger itemIndex = [_sections[section] indexOfObject:item];
|
| + if (itemIndex != NSNotFound) {
|
| + return [NSIndexPath indexPathForItem:itemIndex inSection:section];
|
| + }
|
| + }
|
| + NOTREACHED();
|
| + return nil;
|
| }
|
|
|
| #pragma mark UICollectionView data sourcing
|
|
|