Skip to content

Commit 9544161

Browse files
committed
perf(headlines-feed): optimize followed filter activation logic
- Convert followedTopics to a Set for improved performance - Replace multiple contains checks with containsAll for better efficiency - Maintain existing functionality while optimizing code performance
1 parent 24c982a commit 9544161

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/headlines-feed/view/topic_filter_page.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ class _TopicFilterPageState extends State<TopicFilterPage> {
7373
// Determine if the "Apply My Followed" icon should be filled
7474
// This logic checks if all currently selected topics are
7575
// also present in the fetched followed topics list.
76+
final followedTopicsSet = state.followedTopics.toSet();
7677
final isFollowedFilterActive =
77-
state.followedTopics.isNotEmpty &&
78-
_pageSelectedTopics.length == state.followedTopics.length &&
79-
_pageSelectedTopics.every(state.followedTopics.contains);
78+
followedTopicsSet.isNotEmpty &&
79+
_pageSelectedTopics.length == followedTopicsSet.length &&
80+
_pageSelectedTopics.containsAll(followedTopicsSet);
8081

8182
return IconButton(
8283
icon: isFollowedFilterActive

0 commit comments

Comments
 (0)