Skip to content

Commit 0700ac0

Browse files
committed
feat(entity-details): implement ad placeholders in entity details screen
- Replace ad injection with ad placeholder injection for entity details and pagination - Clear cached ads when loading new entity details to ensure fresh ad content - Update method names in FeedDecoratorService to reflect ad placeholder focus
1 parent b4cd7b4 commit 0700ac0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/entity_details/bloc/entity_details_bloc.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:data_repository/data_repository.dart';
88
import 'package:equatable/equatable.dart';
99
import 'package:flutter/material.dart';
1010
import 'package:flutter_news_app_mobile_client_full_source_code/account/bloc/account_bloc.dart';
11+
import 'package:flutter_news_app_mobile_client_full_source_code/ads/ad_cache_service.dart';
1112
import 'package:flutter_news_app_mobile_client_full_source_code/ads/models/ad_theme_style.dart';
1213
import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart';
1314
import 'package:flutter_news_app_mobile_client_full_source_code/shared/services/feed_decorator_service.dart';
@@ -63,6 +64,9 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
6364
EntityDetailsLoadRequested event,
6465
Emitter<EntityDetailsState> emit,
6566
) async {
67+
// When loading a new entity's details, clear any previously cached ads
68+
// to ensure a fresh set of ads is displayed for the new content.
69+
AdCacheService().clearAllAds();
6670
emit(
6771
state.copyWith(status: EntityDetailsStatus.loading, clearEntity: true),
6872
);
@@ -109,8 +113,9 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
109113
);
110114
}
111115

112-
// For entity details, only inject ads.
113-
final processedFeedItems = await _feedDecoratorService.injectAds(
116+
// For entity details, only inject ad placeholders.
117+
final processedFeedItems =
118+
await _feedDecoratorService.injectAdPlaceholders(
114119
feedItems: headlineResponse.items,
115120
user: currentUser,
116121
adConfig: remoteConfig.adConfig,
@@ -211,8 +216,9 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
211216
);
212217
}
213218

214-
// For entity details pagination, only inject ads.
215-
final newProcessedFeedItems = await _feedDecoratorService.injectAds(
219+
// For entity details pagination, only inject ad placeholders.
220+
final newProcessedFeedItems =
221+
await _feedDecoratorService.injectAdPlaceholders(
216222
feedItems: headlineResponse.items,
217223
user: currentUser,
218224
adConfig: remoteConfig.adConfig,

0 commit comments

Comments
 (0)