Skip to content

Commit 301a1c1

Browse files
committed
refactor(router): wrap SavedHeadlinesPage in BlocProvider for dependency injection
- Add BlocProvider<HeadlinesFeedBloc> to manage dependencies for SavedHeadlinesPage - Inject necessary repositories and services into HeadlinesFeedBloc - Use context.read to access required providers - Set up initialUserContentPreferences for HeadlinesFeedBloc
1 parent 9c37ae9 commit 301a1c1

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/router/router.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,27 @@ GoRouter createRouter({
364364
GoRoute(
365365
path: Routes.accountSavedHeadlines,
366366
name: Routes.accountSavedHeadlinesName,
367-
builder: (context, state) => const SavedHeadlinesPage(),
367+
builder: (context, state) => BlocProvider<HeadlinesFeedBloc>(
368+
create: (context) {
369+
final appBloc = context.read<AppBloc>();
370+
final initialUserContentPreferences =
371+
appBloc.state.userContentPreferences;
372+
return HeadlinesFeedBloc(
373+
headlinesRepository: context.read<DataRepository<Headline>>(),
374+
feedDecoratorService: FeedDecoratorService(),
375+
adService: context.read<AdService>(),
376+
appBloc: appBloc,
377+
inlineAdCacheService: context.read<InlineAdCacheService>(),
378+
feedCacheService: context.read<FeedCacheService>(),
379+
initialUserContentPreferences: initialUserContentPreferences,
380+
engagementRepository: context
381+
.read<DataRepository<Engagement>>(),
382+
contentLimitationService: context
383+
.read<ContentLimitationService>(),
384+
);
385+
},
386+
child: const SavedHeadlinesPage(),
387+
),
368388
),
369389
],
370390
),

0 commit comments

Comments
 (0)