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

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

Issue 2736653002: Suggested Articles can be dismissed (Closed)
Patch Set: Cleanup 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 3fb509f14aefe104bec348c3038c1326ee9dde0e..83b87bd0222f60ec727b1cee7d6339d3b16b08a0 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
@@ -41,6 +41,8 @@ const NSTimeInterval kAnimationDuration = 0.35;
@synthesize suggestionCommandHandler = _suggestionCommandHandler;
@synthesize collectionUpdater = _collectionUpdater;
+#pragma mark - Public
+
- (instancetype)initWithStyle:(CollectionViewControllerStyle)style
dataSource:(id<ContentSuggestionsDataSource>)dataSource {
self = [super initWithStyle:style];
@@ -51,6 +53,19 @@ const NSTimeInterval kAnimationDuration = 0.35;
return self;
}
+- (void)dismissEntryAtIndexPath:(NSIndexPath*)indexPath {
+ if (!indexPath)
+ return;
+
+ [self.collectionView performBatchUpdates:^{
+ [self collectionView:self.collectionView
+ willDeleteItemsAtIndexPaths:@[ indexPath ]];
lpromero 2017/03/06 10:29:00 Why do you call this? So that the item is removed
gambard 2017/03/06 12:16:00 I use performBatchUpdates defensively because the
lpromero 2017/03/06 13:02:30 Can -dismissEntryAtIndexPath: be called several ti
gambard 2017/03/06 17:25:33 For now it should not be called in the same turn o
+
+ [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]];
+ }
+ completion:nil];
+}
+
#pragma mark - UIViewController
- (void)viewDidLoad {
@@ -197,8 +212,10 @@ const NSTimeInterval kAnimationDuration = 0.35;
ContentSuggestionsArticleItem* articleItem =
base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(touchedItem);
- [self.suggestionCommandHandler displayContextMenuForArticle:articleItem
- atPoint:touchLocation];
+ [self.suggestionCommandHandler
+ displayContextMenuForArticle:articleItem
+ atPoint:touchLocation
+ atIndexPath:touchedItemIndexPath];
}
@end

Powered by Google App Engine
This is Rietveld 408576698