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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm

Issue 2739873003: Remove suggestions notified as invalid (Closed)
Patch Set: Update comment 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h" 10 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 [self reloadData]; 123 [self reloadData];
124 } 124 }
125 125
126 #pragma mark - ContentSuggestionsDataSink 126 #pragma mark - ContentSuggestionsDataSink
127 127
128 - (void)dataAvailable { 128 - (void)dataAvailable {
129 [self reloadData]; 129 [self reloadData];
130 } 130 }
131 131
132 - (void)clearSuggestion:(ContentSuggestionIdentifier*)suggestionIdentifier {
133 SectionIdentifier sectionIdentifier =
134 SectionIdentifierForInfo(suggestionIdentifier.sectionInfo);
135 if (![self.collectionViewController.collectionViewModel
136 hasSectionForSectionIdentifier:sectionIdentifier]) {
137 return;
138 }
139
140 NSArray<CollectionViewItem<ContentSuggestionIdentification>*>*
141 itemsInSection = [self.collectionViewController.collectionViewModel
142 itemsInSectionWithIdentifier:sectionIdentifier];
143
144 CollectionViewItem<ContentSuggestionIdentification>* correspondingItem = nil;
145 for (CollectionViewItem<ContentSuggestionIdentification>* item in
146 itemsInSection) {
147 if (item.suggestionIdentifier == suggestionIdentifier) {
148 correspondingItem = item;
149 break;
150 }
151 }
152
153 if (!correspondingItem)
154 return;
155
156 NSIndexPath* indexPath = [self.collectionViewController.collectionViewModel
157 indexPathForItem:correspondingItem
158 inSectionWithIdentifier:sectionIdentifier];
159 [self.collectionViewController dismissEntryAtIndexPath:indexPath];
160 }
161
132 #pragma mark - Public methods 162 #pragma mark - Public methods
133 163
134 - (BOOL)shouldUseCustomStyleForSection:(NSInteger)section { 164 - (BOOL)shouldUseCustomStyleForSection:(NSInteger)section {
135 NSNumber* identifier = @([self.collectionViewController.collectionViewModel 165 NSNumber* identifier = @([self.collectionViewController.collectionViewModel
136 sectionIdentifierForSection:section]); 166 sectionIdentifierForSection:section]);
137 ContentSuggestionsSectionInformation* sectionInformation = 167 ContentSuggestionsSectionInformation* sectionInformation =
138 self.sectionInfoBySectionIdentifier[identifier]; 168 self.sectionInfoBySectionIdentifier[identifier];
139 return sectionInformation.layout == ContentSuggestionsSectionLayoutCustom; 169 return sectionInformation.layout == ContentSuggestionsSectionLayoutCustom;
140 } 170 }
141 171
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 252 }
223 return sectionIdentifier; 253 return sectionIdentifier;
224 } 254 }
225 255
226 - (void)resetModels { 256 - (void)resetModels {
227 [self.collectionViewController loadModel]; 257 [self.collectionViewController loadModel];
228 self.sectionInfoBySectionIdentifier = [[NSMutableDictionary alloc] init]; 258 self.sectionInfoBySectionIdentifier = [[NSMutableDictionary alloc] init];
229 } 259 }
230 260
231 @end 261 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698