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

Unified Diff: ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm

Issue 2775593002: Add a message to empty ContentSuggestions sections (Closed)
Patch Set: Change tests 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
« no previous file with comments | « components/ntp_snippets_strings.grdp ('k') | ios/chrome/browser/ui/content_suggestions/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm b/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
index f9ed02e30fc690818d4f1c6b6cb78b973e29daab..ed03e0942834cd15862878b26d12ddfc38582a5b 100644
--- a/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
@@ -97,10 +97,9 @@ ContentSuggestionsSectionInformation* SectionInformationFromCategoryInfo(
initWithSectionID:SectionIDForCategory(category)];
if (categoryInfo) {
sectionInfo.layout = SectionLayoutForLayout(categoryInfo->card_layout());
- if (categoryInfo->show_if_empty()) {
- // TODO(crbug.com/686728): Creates an item to display information when the
- // section is empty.
- }
+ sectionInfo.showIfEmpty = categoryInfo->show_if_empty();
+ sectionInfo.emptyText =
+ base::SysUTF16ToNSString(categoryInfo->no_suggestions_message());
if (categoryInfo->additional_action() !=
ntp_snippets::ContentSuggestionsAdditionalAction::NONE) {
sectionInfo.footerTitle =
@@ -316,8 +315,8 @@ ntp_snippets::ContentSuggestion::ID SuggestionIDForSectionID(
(const std::vector<ntp_snippets::ContentSuggestion>&)suggestions
fromCategory:(ntp_snippets::Category&)category
toArray:(NSMutableArray<ContentSuggestion*>*)contentArray {
- if (self.contentService->GetCategoryStatus(category) !=
- ntp_snippets::CategoryStatus::AVAILABLE) {
+ if (!ntp_snippets::IsCategoryStatusAvailable(
+ self.contentService->GetCategoryStatus(category))) {
return;
}
@@ -337,6 +336,17 @@ ntp_snippets::ContentSuggestion::ID SuggestionIDForSectionID(
[contentArray addObject:suggestion];
}
+
+ if (suggestions.size() == 0) {
+ ContentSuggestion* suggestion = [[ContentSuggestion alloc] init];
+ suggestion.type = ContentSuggestionTypeEmpty;
+ suggestion.suggestionIdentifier =
+ [[ContentSuggestionIdentifier alloc] init];
+ suggestion.suggestionIdentifier.sectionInfo =
+ self.sectionInformationByCategory[categoryWrapper];
+
+ [contentArray addObject:suggestion];
+ }
}
- (void)addSectionInformationForCategory:(ntp_snippets::Category)category {
« no previous file with comments | « components/ntp_snippets_strings.grdp ('k') | ios/chrome/browser/ui/content_suggestions/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698