Skip to content

Commit eacd1cf

Browse files
committed
feat(entity-details): add country support to follow/unfollow functionality
- Add support for following/unfollowing countries in EntityDetailsBloc - Update filter logic to include country-based filtering for headlines - Extend isCurrentlyFollowing check to support countries
1 parent bf1c3ae commit eacd1cf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/entity_details/bloc/entity_details_bloc.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
197197
_accountBloc.add(AccountFollowTopicToggled(topic: entity));
198198
} else if (entity is Source) {
199199
_accountBloc.add(AccountFollowSourceToggled(source: entity));
200+
} else if (entity is Country) {
201+
_accountBloc.add(AccountFollowCountryToggled(country: entity));
200202
}
201203
}
202204

@@ -218,6 +220,8 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
218220
filter['topic.id'] = (state.entity! as Topic).id;
219221
} else if (state.entity is Source) {
220222
filter['source.id'] = (state.entity! as Source).id;
223+
} else if (state.entity is Country) {
224+
filter['eventCountry.id'] = (state.entity! as Country).id;
221225
}
222226

223227
final headlineResponse = await _headlinesRepository.readAll(
@@ -302,6 +306,10 @@ class EntityDetailsBloc extends Bloc<EntityDetailsEvent, EntityDetailsState> {
302306
isCurrentlyFollowing = preferences.followedSources.any(
303307
(s) => s.id == entity.id,
304308
);
309+
} else if (entity is Country) {
310+
isCurrentlyFollowing = preferences.followedCountries.any(
311+
(c) => c.id == entity.id,
312+
);
305313
}
306314

307315
if (state.isFollowing != isCurrentlyFollowing) {

0 commit comments

Comments
 (0)