Skip to content

Commit 6ffb820

Browse files
committed
refactor(content_management): move topics filter map builder to bloc
- Removed _buildTopicsFilterMap function from TopicsPage - Added buildTopicsFilterMap method to ContentManagementBloc - Updated filter usage in TopicsPage to use the new method from ContentManagementBloc
1 parent d72639e commit 6ffb820

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

lib/content_management/view/topics_page.dart

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,13 @@ class _TopicPageState extends State<TopicPage> {
3131
context.read<ContentManagementBloc>().add(
3232
LoadTopicsRequested(
3333
limit: kDefaultRowsPerPage,
34-
filter: _buildTopicsFilterMap(
35-
context.read<TopicsFilterBloc>().state,
36-
),
34+
filter: context
35+
.read<ContentManagementBloc>()
36+
.buildTopicsFilterMap(context.read<TopicsFilterBloc>().state),
3737
),
3838
);
3939
}
4040

41-
/// Builds a filter map for topics from the given filter state.
42-
Map<String, dynamic> _buildTopicsFilterMap(TopicsFilterState state) {
43-
final filter = <String, dynamic>{};
44-
45-
if (state.searchQuery.isNotEmpty) {
46-
filter['name'] = {r'$regex': state.searchQuery, r'$options': 'i'};
47-
}
48-
49-
filter['status'] = state.selectedStatus.name;
50-
51-
return filter;
52-
}
53-
5441
@override
5542
Widget build(BuildContext context) {
5643
final l10n = AppLocalizationsX(context).l10n;
@@ -74,9 +61,11 @@ class _TopicPageState extends State<TopicPage> {
7461
LoadTopicsRequested(
7562
limit: kDefaultRowsPerPage,
7663
forceRefresh: true,
77-
filter: _buildTopicsFilterMap(
78-
context.read<TopicsFilterBloc>().state,
79-
),
64+
filter: context
65+
.read<ContentManagementBloc>()
66+
.buildTopicsFilterMap(
67+
context.read<TopicsFilterBloc>().state,
68+
),
8069
),
8170
),
8271
);
@@ -129,9 +118,11 @@ class _TopicPageState extends State<TopicPage> {
129118
LoadTopicsRequested(
130119
startAfterId: state.topicsCursor,
131120
limit: kDefaultRowsPerPage,
132-
filter: _buildTopicsFilterMap(
133-
context.read<TopicsFilterBloc>().state,
134-
),
121+
filter: context
122+
.read<ContentManagementBloc>()
123+
.buildTopicsFilterMap(
124+
context.read<TopicsFilterBloc>().state,
125+
),
135126
),
136127
);
137128
}

0 commit comments

Comments
 (0)