Commit 7756d365 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Display the empty section if needed

The ContentSuggestions empty sections can be displayed if their section
info allow them to.
For now they are only displayed if they are started at the opening of
the NTP. This CL fixes it by adding them if needed.

Bug: 765075
Change-Id: Ieb8dde40d14044bfb674bcd9108b84775d1b4531
Reviewed-on: https://chromium-review.googlesource.com/671021Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502833}
parent 7b0bfa07
......@@ -362,6 +362,9 @@ NSString* const kContentSuggestionsCollectionUpdaterSnackbarCategory =
self.collectionViewController.collectionViewModel;
NSInteger sectionIdentifier = SectionIdentifierForInfo(sectionInfo);
if (![model hasSectionForSectionIdentifier:sectionIdentifier])
return nil;
NSArray<CSCollectionViewItem*>* existingItems =
[model itemsInSectionWithIdentifier:sectionIdentifier];
if (existingItems.count == 1 && existingItems[0].type == ItemTypeEmpty) {
......
......@@ -137,10 +137,6 @@ BOOL ShouldCellsBeFullWidth(UITraitCollection* collection) {
- (void)addSuggestions:(NSArray<CSCollectionViewItem*>*)suggestions
toSectionInfo:(ContentSuggestionsSectionInformation*)sectionInfo {
if (suggestions.count == 0) {
return;
}
[self.collectionView performBatchUpdates:^{
NSIndexSet* addedSections = [self.collectionUpdater
addSectionsForSectionInfoToModel:@[ sectionInfo ]];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment