forked from thunder-app/thunder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount_state.dart
64 lines (54 loc) · 1.64 KB
/
account_state.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
part of 'account_bloc.dart';
enum AccountStatus { initial, loading, refreshing, success, empty, failure }
class AccountState extends Equatable {
const AccountState({
this.status = AccountStatus.initial,
this.subsciptions = const [],
this.favorites = const [],
this.moderates = const [],
this.personView,
this.errorMessage,
this.reload = true,
});
final AccountStatus status;
final String? errorMessage;
/// The user's subscriptions if logged in
final List<CommunityView> subsciptions;
/// The user's favorites if logged in
final List<CommunityView> favorites;
/// The user's moderated communities
final List<CommunityModeratorView> moderates;
/// The user's information
final PersonView? personView;
/// Whether changes to the account state should force a reload in certain parts of the app
final bool reload;
AccountState copyWith({
AccountStatus? status,
List<CommunityView>? subsciptions,
List<CommunityView>? favorites,
List<CommunityModeratorView>? moderates,
PersonView? personView,
String? errorMessage,
bool? reload,
}) {
return AccountState(
status: status ?? this.status,
subsciptions: subsciptions ?? this.subsciptions,
favorites: favorites ?? this.favorites,
moderates: moderates ?? this.moderates,
personView: personView ?? this.personView,
errorMessage: errorMessage ?? this.errorMessage,
reload: reload ?? this.reload,
);
}
@override
List<Object?> get props => [
status,
subsciptions,
favorites,
moderates,
personView,
errorMessage,
reload,
];
}