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..bea4610b3f01378aee9f95451d9c242bc4274d53 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 addEmptySectionPlaceholderIfNeeded:indexPath.section]; |
} |
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,15 @@ 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)addEmptySectionPlaceholderIfNeeded:(NSInteger)section { |
+ if ([self.collectionViewModel numberOfItemsInSection:section] > 0) |
+ return; |
+ |
+ NSIndexPath* emptyItem = |
+ [self.collectionUpdater addEmptyItemForSection:section]; |
+ [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; |
+} |
+ |
@end |