Skip to content

Commit 36a7e3c

Browse files
committed
feat(headlines-feed): add followed countries to CountriesFilterState
- Add followedCountriesStatus and followedCountries properties to CountriesFilterState - Update copyWith method to include new parameters for followed countries - Modify props list to include new state properties
1 parent dd2ee66 commit 36a7e3c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lib/headlines-feed/bloc/countries_filter_state.dart

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ final class CountriesFilterState extends Equatable {
3434
this.hasMore = true,
3535
this.cursor,
3636
this.error,
37+
this.followedCountriesStatus = CountriesFilterStatus.initial,
38+
this.followedCountries = const [],
3739
});
3840

3941
/// The current status of fetching countries.
@@ -52,15 +54,24 @@ final class CountriesFilterState extends Equatable {
5254
/// An optional error object if the status is [CountriesFilterStatus.failure].
5355
final HttpException? error;
5456

57+
/// The current status of fetching followed countries.
58+
final CountriesFilterStatus followedCountriesStatus;
59+
60+
/// The list of [Country] objects representing the user's followed countries.
61+
final List<Country> followedCountries;
62+
5563
/// Creates a copy of this state with the given fields replaced.
5664
CountriesFilterState copyWith({
5765
CountriesFilterStatus? status,
5866
List<Country>? countries,
5967
bool? hasMore,
6068
String? cursor,
6169
HttpException? error,
70+
CountriesFilterStatus? followedCountriesStatus,
71+
List<Country>? followedCountries,
6272
bool clearError = false,
6373
bool clearCursor = false,
74+
bool clearFollowedCountriesError = false,
6475
}) {
6576
return CountriesFilterState(
6677
status: status ?? this.status,
@@ -70,9 +81,20 @@ final class CountriesFilterState extends Equatable {
7081
cursor: clearCursor ? null : (cursor ?? this.cursor),
7182
// Clear error if requested, otherwise keep existing or use new one
7283
error: clearError ? null : error ?? this.error,
84+
followedCountriesStatus:
85+
followedCountriesStatus ?? this.followedCountriesStatus,
86+
followedCountries: followedCountries ?? this.followedCountries,
7387
);
7488
}
7589

7690
@override
77-
List<Object?> get props => [status, countries, hasMore, cursor, error];
91+
List<Object?> get props => [
92+
status,
93+
countries,
94+
hasMore,
95+
cursor,
96+
error,
97+
followedCountriesStatus,
98+
followedCountries,
99+
];
78100
}

0 commit comments

Comments
 (0)