Merge feature/source-kinds into ticket/2-source-kinds-learn-tab (#2)
Brings in the News catalog update (#5). ByteByteGo joins the expected on-by-default sets for updated installs, and the catalog test checks the on-by-default set among News sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
a6b8d8b537
6 files changed
+139
-44
No files matched your search
@@ -137,18 +137,21 @@ class AppState extends ChangeNotifier {
|
||||
|
||||
/// Switches on curated sources that are on by default the first time the
|
||||
/// app sees them, so they also reach installs with saved toggles. Sources
|
||||
/// seen before keep whatever the user chose.
|
||||
/// seen before keep whatever the user chose. Saved ids of Sources that are
|
||||
/// no longer in the catalog are dropped.
|
||||
Future<void> _enableNewDefaultSources() async {
|
||||
final saved = _storage.loadEnabledSourceIds();
|
||||
final seen = _storage.loadSeenSourceIds() ??
|
||||
(saved == null ? const <String>{} : legacySeenSourceIds);
|
||||
final unseen = _curated.where((s) => !seen.contains(s.id)).toList();
|
||||
final known = {for (final s in allSources) s.id};
|
||||
enabledSourceIds = {
|
||||
...?saved,
|
||||
...?saved?.where(known.contains),
|
||||
for (final s in unseen)
|
||||
if (s.enabledByDefault) s.id,
|
||||
};
|
||||
if (unseen.isEmpty) return;
|
||||
final dropped = saved != null && saved.any((id) => !known.contains(id));
|
||||
if (unseen.isEmpty && !dropped) return;
|
||||
await _storage.saveSeenSourceIds({...seen, ...unseen.map((s) => s.id)});
|
||||
await _storage.saveEnabledSourceIds(enabledSourceIds);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user