Skip to content

Commit 7164230

Browse files
committed
style: misc
1 parent ab3b5b7 commit 7164230

File tree

10 files changed

+196
-185
lines changed

10 files changed

+196
-185
lines changed

lib/headlines-feed/bloc/headlines_feed_bloc.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import 'package:equatable/equatable.dart';
66
import 'package:ht_data_repository/ht_data_repository.dart'; // Generic Data Repository
77
import 'package:ht_main/headlines-feed/models/headline_filter.dart';
88
import 'package:ht_shared/ht_shared.dart'
9-
show
10-
Category,
11-
// Country, // Removed as it's no longer used for headline filtering
12-
Headline,
13-
HtHttpException,
14-
Source; // Shared models and standardized exceptions
9+
show Headline, HtHttpException; // Shared models and standardized exceptions
1510

1611
part 'headlines_feed_event.dart';
1712
part 'headlines_feed_state.dart';

lib/headlines-feed/bloc/sources_filter_bloc.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import 'dart:async';
33
import 'package:bloc/bloc.dart';
44
import 'package:equatable/equatable.dart';
55
import 'package:ht_data_repository/ht_data_repository.dart';
6-
import 'package:ht_shared/ht_shared.dart'
7-
show Country, HtHttpException, Source, SourceType;
6+
import 'package:ht_shared/ht_shared.dart' show Country, Source, SourceType;
87

98
part 'sources_filter_event.dart';
109
part 'sources_filter_state.dart';

lib/headlines-feed/bloc/sources_filter_event.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,3 @@ class SourceCheckboxToggled extends SourcesFilterEvent {
6464
class ClearSourceFiltersRequested extends SourcesFilterEvent {
6565
const ClearSourceFiltersRequested();
6666
}
67-
68-
// Internal event - not part of public API, hence leading underscore
69-
class _FetchFilteredSourcesRequested extends SourcesFilterEvent {
70-
const _FetchFilteredSourcesRequested();
71-
}

lib/headlines-feed/widgets/headline_item_widget.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:go_router/go_router.dart';
3-
import 'package:ht_main/router/routes.dart';
43
import 'package:ht_main/shared/constants/constants.dart'; // Import AppSpacing
54
import 'package:ht_shared/ht_shared.dart'; // Import models from ht_shared
65
import 'package:intl/intl.dart'; // For date formatting

lib/headlines-search/bloc/headlines_search_bloc.dart

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ class HeadlinesSearchBloc
1515
required HtDataRepository<Category> categoryRepository,
1616
required HtDataRepository<Source> sourceRepository,
1717
required HtDataRepository<Country> countryRepository,
18-
}) : _headlinesRepository = headlinesRepository,
19-
_categoryRepository = categoryRepository,
20-
_sourceRepository = sourceRepository,
21-
_countryRepository = countryRepository,
22-
super(const HeadlinesSearchInitial()) {
18+
}) : _headlinesRepository = headlinesRepository,
19+
_categoryRepository = categoryRepository,
20+
_sourceRepository = sourceRepository,
21+
_countryRepository = countryRepository,
22+
super(const HeadlinesSearchInitial()) {
2323
on<HeadlinesSearchModelTypeChanged>(_onHeadlinesSearchModelTypeChanged);
2424
on<HeadlinesSearchFetchRequested>(
2525
_onSearchFetchRequested,
@@ -38,13 +38,15 @@ class HeadlinesSearchBloc
3838
Emitter<HeadlinesSearchState> emit,
3939
) async {
4040
// If there's an active search term, re-trigger search with new model type
41-
final currentSearchTerm = state is HeadlinesSearchLoading
42-
? (state as HeadlinesSearchLoading).lastSearchTerm
43-
: state is HeadlinesSearchSuccess
41+
// ignore: unused_local_variable
42+
final currentSearchTerm =
43+
state is HeadlinesSearchLoading
44+
? (state as HeadlinesSearchLoading).lastSearchTerm
45+
: state is HeadlinesSearchSuccess
4446
? (state as HeadlinesSearchSuccess).lastSearchTerm
4547
: state is HeadlinesSearchFailure
46-
? (state as HeadlinesSearchFailure).lastSearchTerm
47-
: null;
48+
? (state as HeadlinesSearchFailure).lastSearchTerm
49+
: null;
4850

4951
emit(HeadlinesSearchInitial(selectedModelType: event.newModelType));
5052

@@ -119,42 +121,44 @@ class HeadlinesSearchBloc
119121
emit(successState.copyWith(errorMessage: e.message));
120122
} catch (e, st) {
121123
print('Search pagination error ($modelType): $e\n$st');
122-
emit(successState.copyWith(
123-
errorMessage: 'Failed to load more results.',
124-
));
124+
emit(
125+
successState.copyWith(errorMessage: 'Failed to load more results.'),
126+
);
125127
}
126128
return;
127129
}
128130
}
129131

130132
// New search
131-
emit(HeadlinesSearchLoading(
132-
lastSearchTerm: searchTerm,
133-
selectedModelType: modelType,
134-
));
133+
emit(
134+
HeadlinesSearchLoading(
135+
lastSearchTerm: searchTerm,
136+
selectedModelType: modelType,
137+
),
138+
);
135139
try {
136140
PaginatedResponse<dynamic> response;
137141
switch (modelType) {
138142
case SearchModelType.headline:
139-
response = await _headlinesRepository.readAllByQuery(
140-
{'q': searchTerm, 'model': modelType.toJson()},
141-
limit: _limit,
142-
);
143+
response = await _headlinesRepository.readAllByQuery({
144+
'q': searchTerm,
145+
'model': modelType.toJson(),
146+
}, limit: _limit,);
143147
case SearchModelType.category:
144-
response = await _categoryRepository.readAllByQuery(
145-
{'q': searchTerm, 'model': modelType.toJson()},
146-
limit: _limit,
147-
);
148+
response = await _categoryRepository.readAllByQuery({
149+
'q': searchTerm,
150+
'model': modelType.toJson(),
151+
}, limit: _limit,);
148152
case SearchModelType.source:
149-
response = await _sourceRepository.readAllByQuery(
150-
{'q': searchTerm, 'model': modelType.toJson()},
151-
limit: _limit,
152-
);
153+
response = await _sourceRepository.readAllByQuery({
154+
'q': searchTerm,
155+
'model': modelType.toJson(),
156+
}, limit: _limit,);
153157
case SearchModelType.country:
154-
response = await _countryRepository.readAllByQuery(
155-
{'q': searchTerm, 'model': modelType.toJson()},
156-
limit: _limit,
157-
);
158+
response = await _countryRepository.readAllByQuery({
159+
'q': searchTerm,
160+
'model': modelType.toJson(),
161+
}, limit: _limit,);
158162
}
159163
emit(
160164
HeadlinesSearchSuccess(

0 commit comments

Comments
 (0)