From be71e9ce43db53fd4e1a13ee7736462918dd0da6 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 13 Jun 2023 17:19:19 +0200 Subject: [PATCH] neon_news: simplify FolderFeedsWrapper interface --- packages/neon/neon_news/lib/sort/folders.dart | 2 +- packages/neon/neon_news/lib/widgets/folders_view.dart | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/neon/neon_news/lib/sort/folders.dart b/packages/neon/neon_news/lib/sort/folders.dart index 50ff603d..435cc6a5 100644 --- a/packages/neon/neon_news/lib/sort/folders.dart +++ b/packages/neon/neon_news/lib/sort/folders.dart @@ -11,4 +11,4 @@ final foldersSortBox = SortBox( }, ); -typedef FolderFeedsWrapper = (NextcloudNewsFolder folder, List feeds, int unreadCount); +typedef FolderFeedsWrapper = (NextcloudNewsFolder folder, int feedCount, int unreadCount); diff --git a/packages/neon/neon_news/lib/widgets/folders_view.dart b/packages/neon/neon_news/lib/widgets/folders_view.dart index 2678ec71..6839df97 100644 --- a/packages/neon/neon_news/lib/widgets/folders_view.dart +++ b/packages/neon/neon_news/lib/widgets/folders_view.dart @@ -20,10 +20,11 @@ class NewsFoldersView extends StatelessWidget { input: feeds.data == null ? null : folders.data?.map((final folder) { - final feedsInFolder = feeds.data!.where((final feed) => feed.folderId == folder.id).toList(); + final feedsInFolder = feeds.data!.where((final feed) => feed.folderId == folder.id); + final feedCount = feedsInFolder.length; final unreadCount = feedsInFolder.fold(0, (final a, final b) => a + b.unreadCount!); - return (folder, feedsInFolder, unreadCount); + return (folder, feedCount, unreadCount); }).toList(), builder: (final context, final sorted) => NeonListView( scrollKey: 'news-folders', @@ -42,7 +43,7 @@ class NewsFoldersView extends StatelessWidget { final BuildContext context, final FolderFeedsWrapper folderFeedsWrapper, ) { - final (folder, feeds, unreadCount) = folderFeedsWrapper; + final (folder, feedCount, unreadCount) = folderFeedsWrapper; return ListTile( title: Text( folder.name, @@ -66,7 +67,7 @@ class NewsFoldersView extends StatelessWidget { ), Center( child: Text( - feeds.length.toString(), + feedCount.toString(), style: TextStyle( color: Theme.of(context).colorScheme.onPrimary, ),