Skip to content

Commit cbedf24

Browse files
committed
feat(headlines-search): add default sort by updatedAt in search and load more
- Add sort parameter to readHeadlinesByTerm and readAll calls - Set sort order to descending (newest first) - Update affects both initial search and load more operations
1 parent 26597bd commit cbedf24

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/headlines-search/bloc/headlines_search_bloc.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class HeadlinesSearchBloc
9292
limit: _limit,
9393
cursor: successState.cursor,
9494
),
95+
sort: [const SortOption('updatedAt', SortOrder.desc)],
9596
);
9697
// Cast to List<Headline> for the injector
9798
final headlines = response.items.cast<Headline>();
@@ -202,6 +203,7 @@ class HeadlinesSearchBloc
202203
rawResponse = await _headlinesRepository.readAll(
203204
filter: {'q': searchTerm},
204205
pagination: const PaginationOptions(limit: _limit),
206+
sort: [const SortOption('updatedAt', SortOrder.desc)],
205207
);
206208
final headlines = rawResponse.items.cast<Headline>();
207209
final currentUser = _appBloc.state.user;

0 commit comments

Comments
 (0)