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

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

Issue 2720423003: Get Suggestions image only if it is not empty (Closed)
Patch Set: Fix tests Created 3 years, 10 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_article_item.mm
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm
index 4749f4f7104e4e5a6e9e991f3c909bb4064cd77b..3e3d77b5976ff204109a5cdf01bf05908e06c1ff 100644
--- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_article_item.mm
@@ -19,7 +19,10 @@ const CGFloat kStandardSpacing = 8;
@interface ContentSuggestionsArticleItem ()
@property(nonatomic, copy) NSString* subtitle;
-@property(nonatomic, weak) id<ContentSuggestionsArticleItemDelegate> delegate;
+// Used to check if the image has already been fetched. There is no way to
+// discriminate between failed image download and nonexitent image. The article
+// tries to download the image only once.
+@property(nonatomic, assign) BOOL imageFetched;
@end
@@ -35,7 +38,7 @@ const CGFloat kStandardSpacing = 8;
@synthesize publishDate = _publishDate;
@synthesize suggestionIdentifier = _suggestionIdentifier;
@synthesize delegate = _delegate;
-@synthesize imageBeingFetched = _imageBeingFetched;
+@synthesize imageFetched = _imageFetched;
- (instancetype)initWithType:(NSInteger)type
title:(NSString*)title
@@ -55,7 +58,10 @@ const CGFloat kStandardSpacing = 8;
- (void)configureCell:(ContentSuggestionsArticleCell*)cell {
[super configureCell:cell];
- if (!self.image && !self.imageBeingFetched) {
+ if (!self.image && !self.imageFetched) {
+ self.imageFetched = YES;
+ // Fetch the image. During the fetch the cell's image should still be set to
+ // nil.
[self.delegate loadImageForArticleItem:self];
}
cell.titleLabel.text = _title;

Powered by Google App Engine
This is Rietveld 408576698