Skip to content

Commit a382066

Browse files
committed
refactor(headlines-feed): update ad loading logic in headlines feed
- Replace direct image style retrieval with remote config for ads - Add null check for adConfig and handle null case - Update AdLoaderWidget constructor to use adConfig instead of imageStyle
1 parent a295a02 commit a382066

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/headlines-feed/view/headlines_feed_page.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,21 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage> {
323323
}
324324
return tile;
325325
} else if (item is AdPlaceholder) {
326-
// Retrieve the user's preferred headline image style from the AppBloc.
327-
// This is the single source of truth for this setting.
328-
final imageStyle = context
329-
.watch<AppBloc>()
330-
.state
331-
.settings
332-
.feedPreferences
333-
.headlineImageStyle;
326+
// Access the AppBloc to get the remoteConfig for ads.
327+
final adConfig =
328+
context.read<AppBloc>().state.remoteConfig?.adConfig;
329+
330+
// Ensure adConfig is not null before building the AdLoaderWidget.
331+
if (adConfig == null) {
332+
// Return an empty widget or a placeholder if adConfig is not available.
333+
return const SizedBox.shrink();
334+
}
335+
334336
return AdLoaderWidget(
335337
adPlaceholder: item,
336338
adService: context.read<AdService>(),
337339
adThemeStyle: AdThemeStyle.fromTheme(Theme.of(context)),
338-
imageStyle: imageStyle,
340+
adConfig: adConfig,
339341
);
340342
} else if (item is CallToActionItem) {
341343
return CallToActionDecoratorWidget(

0 commit comments

Comments
 (0)