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

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

Issue 2775593002: Add a message to empty ContentSuggestions sections (Closed)
Patch Set: Reviewable Created 3 years, 9 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
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

Powered by Google App Engine
This is Rietveld 408576698