Chromium Code Reviews| Index: ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm |
| diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm |
| index 4447d4ad793506e02321ee92df81ab1afe255477..aee314583355df94b4a0a5cd741da6c09fd85360 100644 |
| --- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm |
| +++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm |
| @@ -65,6 +65,9 @@ const NSTimeInterval kAnimationDuration = 0.35; |
| willDeleteItemsAtIndexPaths:@[ indexPath ]]; |
| [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]]; |
| + |
| + // Check if the section is now empty. |
| + [self checkEmptySection:indexPath.section]; |
|
lpromero
2017/03/23 10:54:37
Can you update the name of the method, as it does
gambard
2017/03/23 15:25:49
Done.
|
| } |
| completion:^(BOOL) { |
| // The context menu could be displayed for the deleted entry. |
| @@ -140,6 +143,8 @@ const NSTimeInterval kAnimationDuration = 0.35; |
| case ContentSuggestionTypeArticle: |
| [self openArticle:item]; |
| break; |
| + case ContentSuggestionTypeEmpty: |
| + break; |
| } |
| } |
| @@ -267,4 +272,14 @@ const NSTimeInterval kAnimationDuration = 0.35; |
| atIndexPath:touchedItemIndexPath]; |
| } |
| +// Checks if the |section| is empty and add an empty element if it is the case. |
| +// Must be called from inside a performBatchUpdates: block. |
| +- (void)checkEmptySection:(NSInteger)section { |
| + if ([self.collectionViewModel numberOfItemsInSection:section] > 0) |
| + return; |
| + [self.collectionUpdater addEmptyItemForSection:section]; |
| + NSIndexPath* emptyItem = [NSIndexPath indexPathForItem:0 inSection:section]; |
|
lpromero
2017/03/23 10:54:37
Use the return value of –addEmptyItemForSection: o
gambard
2017/03/23 15:25:49
Done.
|
| + [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; |
| +} |
| + |
| @end |