@@ -129,25 +129,55 @@ class _HeadlinesFilterPageState extends State<HeadlinesFilterPage> {
129
129
userId: currentUser.id,
130
130
); // Assuming read by user ID
131
131
132
- setState (() {
133
- _currentUserPreferences = preferences;
134
- _tempSelectedCategories = List .from (preferences.followedCategories);
135
- _tempSelectedSources = List .from (preferences.followedSources);
136
- // We don't auto-apply source country/type filters from user preferences here
137
- // as the "Apply my followed" checkbox is primarily for categories/sources.
138
- // If needed, this logic could be expanded.
139
- _isLoadingFollowedFilters = false ;
140
- });
132
+ // NEW: Check if followed items are empty
133
+ if (preferences.followedCategories.isEmpty &&
134
+ preferences.followedSources.isEmpty) {
135
+ setState (() {
136
+ _isLoadingFollowedFilters = false ;
137
+ _useFollowedFilters = false ; // Uncheck the box
138
+ _tempSelectedCategories = []; // Ensure lists are cleared
139
+ _tempSelectedSources = [];
140
+ });
141
+ if (mounted) {
142
+ ScaffoldMessenger .of (context)
143
+ ..hideCurrentSnackBar ()
144
+ ..showSnackBar (
145
+ SnackBar (
146
+ content: Text (context.l10n.noFollowedItemsForFilterSnackbar),
147
+ duration: const Duration (seconds: 3 ),
148
+ ),
149
+ );
150
+ }
151
+ return ; // Exit the function as no filters to apply
152
+ } else {
153
+ setState (() {
154
+ _currentUserPreferences = preferences;
155
+ _tempSelectedCategories = List .from (preferences.followedCategories);
156
+ _tempSelectedSources = List .from (preferences.followedSources);
157
+ // We don't auto-apply source country/type filters from user preferences here
158
+ // as the "Apply my followed" checkbox is primarily for categories/sources.
159
+ _isLoadingFollowedFilters = false ;
160
+ });
161
+ }
141
162
} on NotFoundException {
142
163
setState (() {
143
164
_currentUserPreferences =
144
165
UserContentPreferences (id: currentUser.id); // Empty prefs
145
166
_tempSelectedCategories = [];
146
167
_tempSelectedSources = [];
147
168
_isLoadingFollowedFilters = false ;
148
- // Optionally, inform user they have no followed items:
149
- // _loadFollowedFiltersError = context.l10n.noFollowedItemsFound;
169
+ _useFollowedFilters = false ; // Uncheck as no prefs found (implies no followed)
150
170
});
171
+ if (mounted) {
172
+ ScaffoldMessenger .of (context)
173
+ ..hideCurrentSnackBar ()
174
+ ..showSnackBar (
175
+ SnackBar (
176
+ content: Text (context.l10n.noFollowedItemsForFilterSnackbar),
177
+ duration: const Duration (seconds: 3 ),
178
+ ),
179
+ );
180
+ }
151
181
} on HtHttpException catch (e) {
152
182
setState (() {
153
183
_isLoadingFollowedFilters = false ;
0 commit comments