Skip to content

Commit 5de9fb5

Browse files
committed
refactor(content_management): update the BlocListener in create_category_page.dart. Instead of dispatching the old LoadCategoriesRequested event (which caused a full reload), it will now dispatch the new CategoryAdded event. This event carries the newly created category object directly to the ContentManagementBloc, which will add it to the list locally for an instant UI update.
1 parent 28bfafe commit 5de9fb5

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/content_management/view/create_category_page.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,16 @@ class _CreateCategoryViewState extends State<_CreateCategoryView> {
7575
listenWhen: (previous, current) => previous.status != current.status,
7676
listener: (context, state) {
7777
if (state.status == CreateCategoryStatus.success &&
78+
state.createdCategory != null &&
7879
ModalRoute.of(context)!.isCurrent) {
7980
ScaffoldMessenger.of(context)
8081
..hideCurrentSnackBar()
8182
..showSnackBar(
82-
SnackBar(
83-
content: Text(l10n.categoryCreatedSuccessfully),
84-
),
83+
SnackBar(content: Text(l10n.categoryCreatedSuccessfully)),
8584
);
8685
context.read<ContentManagementBloc>().add(
87-
const LoadCategoriesRequested(
88-
limit: kDefaultRowsPerPage,
89-
),
90-
);
86+
CategoryAdded(state.createdCategory!),
87+
);
9188
context.pop();
9289
}
9390
if (state.status == CreateCategoryStatus.failure) {

0 commit comments

Comments
 (0)