Skip to content

Commit 5ee4eb0

Browse files
committed
feat(search): Dispatch event on AccountAction shown
- Dispatch event after pagination - Dispatch event after new search
1 parent bd844ab commit 5ee4eb0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/headlines-search/bloc/headlines_search_bloc.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ class HeadlinesSearchBloc
112112
cursor: response.cursor,
113113
),
114114
);
115-
break; // Added break
115+
// Dispatch event if AccountAction was injected during pagination
116+
if (injectedItems.any((item) => item is AccountAction) &&
117+
_appBloc.state.user?.id != null) {
118+
_appBloc.add(AppUserAccountActionShown(userId: _appBloc.state.user!.id));
119+
}
120+
break;
116121
case SearchModelType.category:
117122
response = await _categoryRepository.readAllByQuery(
118123
{'q': searchTerm, 'model': modelType.toJson()},
@@ -208,13 +213,19 @@ class HeadlinesSearchBloc
208213
}
209214
emit(
210215
HeadlinesSearchSuccess(
211-
items: processedItems, // Changed
216+
items: processedItems,
212217
hasMore: rawResponse.hasMore,
213218
cursor: rawResponse.cursor,
214219
lastSearchTerm: searchTerm,
215220
selectedModelType: modelType,
216221
),
217222
);
223+
// Dispatch event if AccountAction was injected in new search
224+
if (modelType == SearchModelType.headline &&
225+
processedItems.any((item) => item is AccountAction) &&
226+
_appBloc.state.user?.id != null) {
227+
_appBloc.add(AppUserAccountActionShown(userId: _appBloc.state.user!.id));
228+
}
218229
} on HtHttpException catch (e) {
219230
emit(
220231
HeadlinesSearchFailure(

0 commit comments

Comments
 (0)