@@ -16,13 +16,15 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
16
16
required HtDataRepository <Category > categoryRepository,
17
17
required HtDataRepository <Source > sourceRepository,
18
18
required AccountBloc accountBloc, // Changed to AccountBloc
19
- }) : _headlinesRepository = headlinesRepository,
20
- _categoryRepository = categoryRepository,
21
- _sourceRepository = sourceRepository,
22
- _accountBloc = accountBloc,
23
- super (const EntityDetailsState ()) {
19
+ }) : _headlinesRepository = headlinesRepository,
20
+ _categoryRepository = categoryRepository,
21
+ _sourceRepository = sourceRepository,
22
+ _accountBloc = accountBloc,
23
+ super (const EntityDetailsState ()) {
24
24
on < EntityDetailsLoadRequested > (_onEntityDetailsLoadRequested);
25
- on < EntityDetailsToggleFollowRequested > (_onEntityDetailsToggleFollowRequested);
25
+ on < EntityDetailsToggleFollowRequested > (
26
+ _onEntityDetailsToggleFollowRequested,
27
+ );
26
28
on < EntityDetailsLoadMoreHeadlinesRequested > (
27
29
_onEntityDetailsLoadMoreHeadlinesRequested,
28
30
);
@@ -50,7 +52,9 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
50
52
EntityDetailsLoadRequested event,
51
53
Emitter <EntityDetailsState > emit,
52
54
) async {
53
- emit (state.copyWith (status: EntityDetailsStatus .loading, clearEntity: true ));
55
+ emit (
56
+ state.copyWith (status: EntityDetailsStatus .loading, clearEntity: true ),
57
+ );
54
58
55
59
dynamic entityToLoad = event.entity;
56
60
EntityType ? entityTypeToLoad = event.entityType;
@@ -62,8 +66,7 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
62
66
event.entityType != null ) {
63
67
entityTypeToLoad = event.entityType; // Ensure type is set
64
68
if (event.entityType == EntityType .category) {
65
- entityToLoad =
66
- await _categoryRepository.read (id: event.entityId! );
69
+ entityToLoad = await _categoryRepository.read (id: event.entityId! );
67
70
} else if (event.entityType == EntityType .source) {
68
71
entityToLoad = await _sourceRepository.read (id: event.entityId! );
69
72
} else {
@@ -109,11 +112,15 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
109
112
if (currentAccountState.preferences != null ) {
110
113
if (entityTypeToLoad == EntityType .category &&
111
114
entityToLoad is Category ) {
112
- isCurrentlyFollowing = currentAccountState.preferences! .followedCategories
115
+ isCurrentlyFollowing = currentAccountState
116
+ .preferences!
117
+ .followedCategories
113
118
.any ((cat) => cat.id == entityToLoad.id);
114
119
} else if (entityTypeToLoad == EntityType .source &&
115
- entityToLoad is Source ) {
116
- isCurrentlyFollowing = currentAccountState.preferences! .followedSources
120
+ entityToLoad is Source ) {
121
+ isCurrentlyFollowing = currentAccountState
122
+ .preferences!
123
+ .followedSources
117
124
.any ((src) => src.id == entityToLoad.id);
118
125
}
119
126
}
@@ -173,7 +180,7 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
173
180
AccountFollowCategoryToggled (category: state.entity as Category ),
174
181
);
175
182
} else if (state.entityType == EntityType .source &&
176
- state.entity is Source ) {
183
+ state.entity is Source ) {
177
184
_accountBloc.add (
178
185
AccountFollowSourceToggled (source: state.entity as Source ),
179
186
);
@@ -264,13 +271,15 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
264
271
265
272
if (state.entityType == EntityType .category && state.entity is Category ) {
266
273
final currentCategory = state.entity as Category ;
267
- isCurrentlyFollowing = preferences.followedCategories
268
- .any ((cat) => cat.id == currentCategory.id);
274
+ isCurrentlyFollowing = preferences.followedCategories.any (
275
+ (cat) => cat.id == currentCategory.id,
276
+ );
269
277
} else if (state.entityType == EntityType .source &&
270
- state.entity is Source ) {
278
+ state.entity is Source ) {
271
279
final currentSource = state.entity as Source ;
272
- isCurrentlyFollowing = preferences.followedSources
273
- .any ((src) => src.id == currentSource.id);
280
+ isCurrentlyFollowing = preferences.followedSources.any (
281
+ (src) => src.id == currentSource.id,
282
+ );
274
283
}
275
284
276
285
if (state.isFollowing != isCurrentlyFollowing) {
0 commit comments