Skip to content

Commit f5ad54a

Browse files
committed
refactor(content_management): update the BlocListener in edit_category_page.dart. When an edit is successful, it will now dispatch the new CategoryUpdated event, passing the updated category object directly to the ContentManagementBloc. This allows the main list to update the specific item locally, which is much more efficient than reloading the entire list.
1 parent 5de9fb5 commit f5ad54a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/content_management/view/edit_category_page.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class _EditCategoryViewState extends State<_EditCategoryView> {
101101
previous.initialCategory != current.initialCategory,
102102
listener: (context, state) {
103103
if (state.status == EditCategoryStatus.success &&
104-
state.initialCategory != null &&
104+
state.updatedCategory != null &&
105105
ModalRoute.of(context)!.isCurrent) {
106106
ScaffoldMessenger.of(context)
107107
..hideCurrentSnackBar()
@@ -110,10 +110,8 @@ class _EditCategoryViewState extends State<_EditCategoryView> {
110110
const SnackBar(content: Text('Category updated successfully.')),
111111
);
112112
context.read<ContentManagementBloc>().add(
113-
const LoadCategoriesRequested(
114-
limit: kDefaultRowsPerPage,
115-
),
116-
);
113+
CategoryUpdated(state.updatedCategory!),
114+
);
117115
context.pop();
118116
}
119117
if (state.status == EditCategoryStatus.failure) {

0 commit comments

Comments
 (0)