Add source kinds and the Learn tab with Learning sources (#2)
Every Source now has a kind: News, Learning or Fun. Curated Sources default to News, and custom Sources persist their kind (ones saved before default to News). Each kind has its own time window: News follows the 12/24/48 h setting, Learning reaches back 14 days, Fun 3 days. A new Learn tab between Briefing and Sources lists Learning articles with the same paid/sponsored filters and reader view as Today. It is built from a list of kinds so a Fun section can follow. Today and the Briefing only use News. ByteByteGo is the first Learning source, on by default. The home shell names its tabs instead of using hard-coded indexes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8c8ffca5dc
commit
64c4a11105
12 files changed
+498
-32
No files matched your search
@@ -23,14 +23,15 @@ class FeedService {
|
||||
|
||||
static const _timeout = Duration(seconds: 20);
|
||||
|
||||
/// Fetches all [sources] in parallel. Failing feeds are reported in
|
||||
/// Fetches all [sources] in parallel and drops articles older than the age
|
||||
/// [maxAgeOf] gives for their Source. Failing feeds are reported in
|
||||
/// [FeedResult.errors] instead of failing the whole refresh.
|
||||
///
|
||||
/// [corsProxy] is only used on web, where browsers block cross-origin feed
|
||||
/// requests. It is prepended to the feed URL, e.g. `https://proxy/?url=`.
|
||||
Future<FeedResult> fetchAll(
|
||||
List<NewsSource> sources, {
|
||||
required Duration maxAge,
|
||||
required Duration Function(NewsSource source) maxAgeOf,
|
||||
String corsProxy = '',
|
||||
}) async {
|
||||
final errors = <String, String>{};
|
||||
@@ -43,12 +44,15 @@ class FeedService {
|
||||
}
|
||||
}));
|
||||
|
||||
final cutoff = DateTime.now().toUtc().subtract(maxAge);
|
||||
final now = DateTime.now().toUtc();
|
||||
final seen = <String>{};
|
||||
final articles = <Article>[
|
||||
for (final list in results)
|
||||
for (final (i, list) in results.indexed)
|
||||
for (final a in list)
|
||||
if ((a.published == null || a.published!.isAfter(cutoff)) && seen.add(a.id)) a,
|
||||
if ((a.published == null ||
|
||||
a.published!.isAfter(now.subtract(maxAgeOf(sources[i])))) &&
|
||||
seen.add(a.id))
|
||||
a,
|
||||
];
|
||||
articles.sort((a, b) {
|
||||
final pa = a.published, pb = b.published;
|
||||
|
||||
Reference in new issue
Block a user