Skip to content

Commit 1ca46d1

Browse files
committed
fix(headlines-feed): toggle follow status for topics and sources
- Add AccountFollowTopicToggled and AccountFollowSourceToggled events to AccountBloc - Remove SuggestedItemFollowToggled event from HeadlinesFeedBloc - Add context.read<AccountBloc>().add() calls for both Topic and Source toggles - Remove unused local variable comment for isCurrentlyFollowing
1 parent 4467e65 commit 1ca46d1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/headlines-feed/view/headlines_feed_page.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,26 +339,29 @@ class _HeadlinesFeedPageState extends State<HeadlinesFeedPage> {
339339
followedSourceIds: followedSourceIds,
340340
onFollowToggle: (toggledItem) {
341341
// Determine the current following status to toggle it.
342+
// ignore: unused_local_variable
342343
final bool isCurrentlyFollowing;
343344
if (toggledItem is Topic) {
344345
isCurrentlyFollowing = followedTopicIds.contains(
345346
toggledItem.id,
346347
);
348+
context.read<AccountBloc>().add(
349+
AccountFollowTopicToggled(
350+
topic: toggledItem,
351+
),
352+
);
347353
} else if (toggledItem is Source) {
348354
isCurrentlyFollowing = followedSourceIds.contains(
349355
toggledItem.id,
350356
);
357+
context.read<AccountBloc>().add(
358+
AccountFollowSourceToggled(
359+
source: toggledItem,
360+
),
361+
);
351362
} else {
352363
return; // Should not happen
353364
}
354-
355-
// Dispatch the event with the NEW following status.
356-
context.read<HeadlinesFeedBloc>().add(
357-
SuggestedItemFollowToggled(
358-
item: toggledItem,
359-
isFollowing: !isCurrentlyFollowing,
360-
),
361-
);
362365
},
363366
onDismiss: (decoratorType) {
364367
context.read<HeadlinesFeedBloc>().add(

0 commit comments

Comments
 (0)