Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(918)

Unified Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm

Issue 2923973002: Reload the Most Visited section when it changes (Closed)
Patch Set: Address comment Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm
index f5cebf7a5936bc8170a99169ae2ff2e3fde59a79..da6e94426458f80f877d0084a95ac6a954b4da28 100644
--- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm
@@ -221,7 +221,33 @@ const CGFloat kNumberOfMostVisitedLines = 2;
}
- (void)reloadSection:(ContentSuggestionsSectionInformation*)sectionInfo {
- // TODO(crbug.com/707754): implement this method.
+ CSCollectionViewModel* model =
+ self.collectionViewController.collectionViewModel;
+ SectionIdentifier sectionIdentifier = SectionIdentifierForInfo(sectionInfo);
+
+ if (![model hasSectionForSectionIdentifier:sectionIdentifier]) {
+ [self.collectionViewController
+ addSuggestions:[self.dataSource itemsForSectionInfo:sectionInfo]
+ toSectionInfo:sectionInfo];
+ return;
+ }
+
+ NSInteger section = [model sectionForSectionIdentifier:sectionIdentifier];
+
+ NSMutableArray* oldItems = [NSMutableArray array];
+ NSInteger numberOfItems = [model numberOfItemsInSection:section];
+ for (NSInteger i = 0; i < numberOfItems; i++) {
+ [oldItems addObject:[NSIndexPath indexPathForItem:i inSection:section]];
+ }
+ [self.collectionViewController
+ collectionView:self.collectionViewController.collectionView
+ willDeleteItemsAtIndexPaths:oldItems];
+
+ [self addSuggestionsToModel:[self.dataSource itemsForSectionInfo:sectionInfo]
+ withSectionInfo:sectionInfo];
+
+ [self.collectionViewController.collectionView
+ reloadSections:[NSIndexSet indexSetWithIndex:section]];
}
- (void)faviconAvailableForItem:(CollectionViewItem<SuggestedContent>*)item {
« no previous file with comments | « ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698