feat: store subscription posts with a read mark and split the library controller

This commit is contained in:
randogoth 2026-10-11 13:12:48 +03:00
parent b311b9f7dd
commit 953ae798eb
15 changed files with 1787 additions and 386 deletions

View file

@ -1,16 +1,15 @@
import '../../database/database.dart';
import '../../l10n/strings.dart';
import '../../mews/document.dart';
import '../controllers/reader_settings_controller.dart' show LibraryController;
import 'page_blocks.dart';
Future<MewsPage> buildSubscriptionsPage(
Uri url, {
required MewsDatabase db,
required LibraryController library,
required Strings strings,
}) async {
final sites = await db.allSubscriptions();
final unread = await db.unreadCounts();
final title = strings.t('subscriptions-title');
return internalPage(
@ -27,17 +26,16 @@ Future<MewsPage> buildSubscriptionsPage(
href: site.url,
label: site.title ?? site.url,
date: dayText(site.createdAt),
note: _unreadNote(library, strings, site.url),
note: _unreadNote(strings, unread[site.url] ?? 0),
),
]),
],
);
}
/// The unread count for a site, or null when it has nothing new, so the row
/// carries no empty line.
String? _unreadNote(LibraryController library, Strings strings, String siteUrl) {
final count = library.newEntries.value[siteUrl]?.length ?? 0;
/// The unread count for a site, or null when it has nothing unread, so the
/// row carries no second line.
String? _unreadNote(Strings strings, int count) {
if (count == 0) return null;
return countText(strings, count,
none: 'count-unread-none',