@@ -119,10 +119,6 @@ class HeadlinesFeedBloc extends Bloc<HeadlinesFeedEvent, HeadlinesFeedState> {
119119 _onHeadlinesFeedFiltersCleared,
120120 transformer: restartable (),
121121 );
122- on < FeedDecoratorDismissed > (
123- _onFeedDecoratorDismissed,
124- transformer: sequential (),
125- );
126122 on < CallToActionTapped > (_onCallToActionTapped, transformer: sequential ());
127123 on < NavigationHandled > (_onNavigationHandled, transformer: sequential ());
128124 on < _AppContentPreferencesChanged > (_onAppContentPreferencesChanged);
@@ -717,73 +713,6 @@ class HeadlinesFeedBloc extends Bloc<HeadlinesFeedEvent, HeadlinesFeedState> {
717713 }
718714 }
719715
720- Future <void > _onFeedDecoratorDismissed (
721- FeedDecoratorDismissed event,
722- Emitter <HeadlinesFeedState > emit,
723- ) async {
724- _logger.info (
725- 'Dismissing decorator: ${event .feedDecoratorType }. '
726- 'Updating cache and UI.' ,
727- );
728- final currentUser = _appBloc.state.user;
729- if (currentUser == null ) return ;
730-
731- // First, notify the AppBloc that the user has completed this action.
732- // This prevents the decorator from being shown again in future sessions.
733- _appBloc.add (
734- AppUserFeedDecoratorShown (
735- userId: currentUser.id,
736- feedDecoratorType: event.feedDecoratorType,
737- isCompleted: true ,
738- ),
739- );
740-
741- // Second, update the in-memory cache for the current session.
742- // This ensures the decorator is removed immediately from the current view
743- // and does not reappear when switching between feed filters.
744- final filterKey = _generateFilterKey (state.activeFilterId! , state.filter);
745- final cachedFeed = _feedCacheService.getFeed (filterKey);
746-
747- if (cachedFeed == null ) {
748- _logger.warning (
749- 'Cannot update cache on decorator dismissal: '
750- 'No cached feed found for key "$filterKey ".' ,
751- );
752- // Fallback to just removing from the UI state if cache is not found.
753- final newFeedItems = List <FeedItem >.from (state.feedItems)
754- ..removeWhere ((item) {
755- if (item is CallToActionItem ) {
756- return item.decoratorType == event.feedDecoratorType;
757- }
758- if (item is ContentCollectionItem ) {
759- return item.decoratorType == event.feedDecoratorType;
760- }
761- return false ;
762- });
763- emit (state.copyWith (feedItems: newFeedItems));
764- return ;
765- }
766-
767- // Perform the "read-modify-write" cycle on the cache.
768- final newFeedItems = List <FeedItem >.from (cachedFeed.feedItems)
769- ..removeWhere ((item) {
770- if (item is CallToActionItem ) {
771- return item.decoratorType == event.feedDecoratorType;
772- } else if (item is ContentCollectionItem ) {
773- return item.decoratorType == event.feedDecoratorType;
774- }
775- return false ;
776- });
777-
778- final updatedCachedFeed = cachedFeed.copyWith (feedItems: newFeedItems);
779- _feedCacheService.setFeed (filterKey, updatedCachedFeed);
780- _logger.info (
781- 'Cache for key "$filterKey " updated after decorator dismissal.' ,
782- );
783-
784- emit (state.copyWith (feedItems: newFeedItems));
785- }
786-
787716 Future <void > _onCallToActionTapped (
788717 CallToActionTapped event,
789718 Emitter <HeadlinesFeedState > emit,
0 commit comments