1
1
import 'package:bloc/bloc.dart' ;
2
2
import 'package:equatable/equatable.dart' ;
3
- import 'package:ht_headlines_client/ht_headlines_client .dart' ;
4
- import 'package:ht_headlines_repository/ht_headlines_repository .dart' ;
3
+ import 'package:ht_data_repository/ht_data_repository .dart' ; // Generic Data Repository
4
+ import 'package:ht_shared/ht_shared .dart' ; // Shared models, including Headline
5
5
6
6
part 'headlines_search_event.dart' ;
7
7
part 'headlines_search_state.dart' ;
8
8
9
9
class HeadlinesSearchBloc
10
10
extends Bloc <HeadlinesSearchEvent , HeadlinesSearchState > {
11
- HeadlinesSearchBloc ({required HtHeadlinesRepository headlinesRepository})
11
+ HeadlinesSearchBloc ({required HtDataRepository < Headline > headlinesRepository})
12
12
: _headlinesRepository = headlinesRepository,
13
13
super (HeadlinesSearchLoading ()) {
14
14
on < HeadlinesSearchFetchRequested > (_onSearchFetchRequested);
15
15
}
16
16
17
- final HtHeadlinesRepository _headlinesRepository;
17
+ final HtDataRepository < Headline > _headlinesRepository;
18
18
static const _limit = 10 ;
19
19
20
20
Future <void > _onSearchFetchRequested (
@@ -38,8 +38,8 @@ class HeadlinesSearchBloc
38
38
if (! currentState.hasMore) return ;
39
39
40
40
try {
41
- final response = await _headlinesRepository.searchHeadlines (
42
- query: event.searchTerm,
41
+ final response = await _headlinesRepository.readAllByQuery (
42
+ { ' query' : event.searchTerm}, // Use query map
43
43
limit: _limit,
44
44
startAfterId: currentState.cursor,
45
45
);
@@ -58,8 +58,8 @@ class HeadlinesSearchBloc
58
58
}
59
59
} else {
60
60
try {
61
- final response = await _headlinesRepository.searchHeadlines (
62
- query: event.searchTerm,
61
+ final response = await _headlinesRepository.readAllByQuery (
62
+ { ' query' : event.searchTerm}, // Use query map
63
63
limit: _limit,
64
64
);
65
65
emit (
0 commit comments