Skip to content

Commit a9801e8

Browse files
committed
refactor(content_management): update the BlocListener in create_headline_page.dart. Instead of triggering a full data reload, it will now dispatch the new HeadlineAdded event. This event passes the newly created headline object directly to the ContentManagementBloc, which will add it to the list locally for an immediate and efficient UI update.
1 parent f5ad54a commit a9801e8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/content_management/view/create_headline_page.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,16 @@ class _CreateHeadlineViewState extends State<_CreateHeadlineView> {
7777
listenWhen: (previous, current) => previous.status != current.status,
7878
listener: (context, state) {
7979
if (state.status == CreateHeadlineStatus.success &&
80+
state.createdHeadline != null &&
8081
ModalRoute.of(context)!.isCurrent) {
8182
ScaffoldMessenger.of(context)
8283
..hideCurrentSnackBar()
8384
..showSnackBar(
84-
SnackBar(
85-
content: Text(l10n.headlineCreatedSuccessfully),
86-
),
85+
SnackBar(content: Text(l10n.headlineCreatedSuccessfully)),
8786
);
8887
context.read<ContentManagementBloc>().add(
89-
const LoadHeadlinesRequested(
90-
limit: kDefaultRowsPerPage,
91-
),
92-
);
88+
HeadlineAdded(state.createdHeadline!),
89+
);
9390
context.pop();
9491
}
9592
if (state.status == CreateHeadlineStatus.failure) {

0 commit comments

Comments
 (0)