@@ -98,7 +98,7 @@ class _FeedAdLoaderWidgetState extends State<FeedAdLoaderWidget> {
9898 // completed. This prevents a race condition if a new load is triggered
9999 // while an old one is still in progress.
100100 if (_loadAdCompleter != null && ! _loadAdCompleter! .isCompleted) {
101- _loadAdCompleter! .complete (); // Complete normally to prevent crashes
101+ _loadAdCompleter! .complete ();
102102 }
103103 _loadAdCompleter = null ;
104104
@@ -125,7 +125,7 @@ class _FeedAdLoaderWidgetState extends State<FeedAdLoaderWidget> {
125125 // This prevents `setState()` calls on a disposed widget.
126126 // Ensure the completer is not already completed before attempting to complete it.
127127 if (_loadAdCompleter != null && ! _loadAdCompleter! .isCompleted) {
128- _loadAdCompleter! .complete (); // Complete normally to prevent crashes
128+ _loadAdCompleter! .complete ();
129129 }
130130 _loadAdCompleter = null ;
131131 super .dispose ();
@@ -203,18 +203,18 @@ class _FeedAdLoaderWidgetState extends State<FeedAdLoaderWidget> {
203203 return ;
204204 }
205205
206- // Get the current HeadlineImageStyle from AppBloc
207- final headlineImageStyle = context
208- .read <AppBloc >()
209- .state
210- .headlineImageStyle;
206+ // Get the current HeadlineImageStyle and user role from AppBloc
207+ final appBlocState = context.read <AppBloc >().state;
208+ final headlineImageStyle = appBlocState.headlineImageStyle;
209+ final userRole = appBlocState.user? .appRole ?? AppUserRole .guestUser;
211210
212211 // Call AdService.getFeedAd with the full AdConfig and adType from the placeholder.
213212 final loadedAd = await _adService.getFeedAd (
214- adConfig: widget.adConfig, // Pass the full AdConfig
213+ adConfig: widget.adConfig,
215214 adType: widget.adPlaceholder.adType,
216215 adThemeStyle: widget.adThemeStyle,
217- headlineImageStyle: headlineImageStyle, // Pass the headlineImageStyle
216+ headlineImageStyle: headlineImageStyle,
217+ userRole: userRole,
218218 );
219219
220220 if (loadedAd != null ) {
0 commit comments