Skip to content

Commit 7000630

Browse files
authored
Merge pull request #30 from headlines-toolkit/refactor_remove_country_from_search_and_headline_details_page
Refactor remove country from search and headline details page
2 parents 3378849 + 0f1b8ce commit 7000630

19 files changed

+442
-998
lines changed

lib/account/bloc/account_bloc.dart

Lines changed: 195 additions & 184 deletions
Large diffs are not rendered by default.

lib/account/bloc/account_event.dart

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,58 @@
11
part of 'account_bloc.dart';
22

3-
/// {@template account_event}
4-
/// Base class for Account events.
5-
/// {@endtemplate}
6-
sealed class AccountEvent extends Equatable {
7-
/// {@macro account_event}
3+
abstract class AccountEvent extends Equatable {
84
const AccountEvent();
95

106
@override
117
List<Object?> get props => [];
128
}
139

14-
/// {@template _account_user_changed}
15-
/// Internal event triggered when the authenticated user changes.
16-
/// {@endtemplate}
17-
final class _AccountUserChanged extends AccountEvent {
18-
/// {@macro _account_user_changed}
19-
const _AccountUserChanged({required this.user});
20-
21-
/// The current authenticated user, or null if unauthenticated.
10+
class AccountUserChanged extends AccountEvent { // Corrected name
11+
const AccountUserChanged(this.user);
2212
final User? user;
2313

2414
@override
2515
List<Object?> get props => [user];
2616
}
2717

28-
/// {@template account_load_content_preferences_requested}
29-
/// Event triggered when the user's content preferences need to be loaded.
30-
/// {@endtemplate}
31-
final class AccountLoadContentPreferencesRequested extends AccountEvent {
32-
/// {@macro account_load_content_preferences_requested}
33-
const AccountLoadContentPreferencesRequested({required this.userId});
34-
35-
/// The ID of the user whose content preferences should be loaded.
18+
class AccountLoadUserPreferences extends AccountEvent { // Corrected name
19+
const AccountLoadUserPreferences({required this.userId});
3620
final String userId;
3721

3822
@override
3923
List<Object> get props => [userId];
4024
}
4125

42-
/// {@template account_follow_category_toggled}
43-
/// Event triggered when a user toggles following a category.
44-
/// {@endtemplate}
45-
final class AccountFollowCategoryToggled extends AccountEvent {
46-
/// {@macro account_follow_category_toggled}
47-
const AccountFollowCategoryToggled({required this.category});
26+
class AccountSaveHeadlineToggled extends AccountEvent {
27+
const AccountSaveHeadlineToggled({required this.headline});
28+
final Headline headline;
4829

30+
@override
31+
List<Object> get props => [headline];
32+
}
33+
34+
class AccountFollowCategoryToggled extends AccountEvent {
35+
const AccountFollowCategoryToggled({required this.category});
4936
final Category category;
5037

5138
@override
5239
List<Object> get props => [category];
5340
}
5441

55-
/// {@template account_follow_source_toggled}
56-
/// Event triggered when a user toggles following a source.
57-
/// {@endtemplate}
58-
final class AccountFollowSourceToggled extends AccountEvent {
59-
/// {@macro account_follow_source_toggled}
42+
class AccountFollowSourceToggled extends AccountEvent {
6043
const AccountFollowSourceToggled({required this.source});
61-
6244
final Source source;
6345

6446
@override
6547
List<Object> get props => [source];
6648
}
6749

68-
/// {@template account_follow_country_toggled}
69-
/// Event triggered when a user toggles following a country.
70-
/// {@endtemplate}
71-
final class AccountFollowCountryToggled extends AccountEvent {
72-
/// {@macro account_follow_country_toggled}
73-
const AccountFollowCountryToggled({required this.country});
50+
// AccountFollowCountryToggled event correctly removed previously
7451

75-
final Country country;
76-
77-
@override
78-
List<Object> get props => [country];
79-
}
80-
81-
/// {@template account_save_headline_toggled}
82-
/// Event triggered when a user toggles saving a headline.
83-
/// {@endtemplate}
84-
final class AccountSaveHeadlineToggled extends AccountEvent {
85-
/// {@macro account_save_headline_toggled}
86-
const AccountSaveHeadlineToggled({required this.headline});
87-
88-
final Headline headline;
52+
class AccountClearUserPreferences extends AccountEvent {
53+
const AccountClearUserPreferences({required this.userId});
54+
final String userId;
8955

9056
@override
91-
List<Object> get props => [headline];
57+
List<Object> get props => [userId];
9258
}

lib/account/bloc/account_state.dart

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,36 @@
11
part of 'account_bloc.dart';
22

3-
/// Defines the status of the account state.
4-
enum AccountStatus {
5-
/// The initial state.
6-
initial,
3+
enum AccountStatus { initial, loading, success, failure }
74

8-
/// An operation is in progress.
9-
loading,
10-
11-
/// An operation was successful.
12-
success,
13-
14-
/// An operation failed.
15-
failure,
16-
}
17-
18-
/// {@template account_state}
19-
/// State for the Account feature.
20-
/// {@endtemplate}
21-
final class AccountState extends Equatable {
22-
/// {@macro account_state}
5+
class AccountState extends Equatable {
236
const AccountState({
247
this.status = AccountStatus.initial,
258
this.user,
269
this.preferences,
2710
this.errorMessage,
2811
});
2912

30-
/// The current status of the account state.
3113
final AccountStatus status;
32-
33-
/// The currently authenticated user.
3414
final User? user;
35-
36-
/// The user's content preferences.
3715
final UserContentPreferences? preferences;
38-
39-
/// An error message if an operation failed.
4016
final String? errorMessage;
4117

42-
/// Creates a copy of this [AccountState] with the given fields replaced.
4318
AccountState copyWith({
4419
AccountStatus? status,
4520
User? user,
4621
UserContentPreferences? preferences,
4722
String? errorMessage,
23+
bool clearUser = false,
24+
bool clearPreferences = false,
25+
bool clearErrorMessage = false,
4826
}) {
4927
return AccountState(
5028
status: status ?? this.status,
51-
user: user ?? this.user,
52-
preferences: preferences ?? this.preferences,
53-
errorMessage: errorMessage ?? this.errorMessage,
29+
user: clearUser ? null : user ?? this.user,
30+
preferences:
31+
clearPreferences ? null : preferences ?? this.preferences,
32+
errorMessage:
33+
clearErrorMessage ? null : errorMessage ?? this.errorMessage,
5434
);
5535
}
5636

lib/account/bloc/available_countries_bloc.dart

Lines changed: 0 additions & 56 deletions
This file was deleted.

lib/account/bloc/available_countries_event.dart

Lines changed: 0 additions & 12 deletions
This file was deleted.

lib/account/bloc/available_countries_state.dart

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)