From 7fa3a8e6f5db282b1840a98c96adf25c91b7f4ea Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 13 Jun 2023 17:19:18 +0200 Subject: [PATCH] neon_news: make feedsUnreadCountSum a property of FolderFeedsWrapper --- packages/neon/neon_news/lib/sort/folders.dart | 5 ++--- packages/neon/neon_news/lib/widgets/folders_view.dart | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/neon/neon_news/lib/sort/folders.dart b/packages/neon/neon_news/lib/sort/folders.dart index b769ad8b..05cf9813 100644 --- a/packages/neon/neon_news/lib/sort/folders.dart +++ b/packages/neon/neon_news/lib/sort/folders.dart @@ -3,7 +3,7 @@ part of '../neon_news.dart'; final foldersSortBox = SortBox( { FoldersSortProperty.alphabetical: (final folderFeedsWrapper) => folderFeedsWrapper.folder.name.toLowerCase(), - FoldersSortProperty.unreadCount: (final folderFeedsWrapper) => feedsUnreadCountSum(folderFeedsWrapper.feeds), + FoldersSortProperty.unreadCount: (final folderFeedsWrapper) => folderFeedsWrapper.feedsUnreadCountSum, }, { FoldersSortProperty.alphabetical: Box(FoldersSortProperty.unreadCount, SortBoxOrder.descending), @@ -19,6 +19,5 @@ class FolderFeedsWrapper { final NextcloudNewsFolder folder; final List feeds; + int get feedsUnreadCountSum => feeds.fold(0, (final a, final b) => a + b.unreadCount!); } - -int feedsUnreadCountSum(final List feeds) => feeds.fold(0, (final a, final b) => a + b.unreadCount!); diff --git a/packages/neon/neon_news/lib/widgets/folders_view.dart b/packages/neon/neon_news/lib/widgets/folders_view.dart index df8e457d..6b351aee 100644 --- a/packages/neon/neon_news/lib/widgets/folders_view.dart +++ b/packages/neon/neon_news/lib/widgets/folders_view.dart @@ -44,7 +44,7 @@ class NewsFoldersView extends StatelessWidget { final BuildContext context, final FolderFeedsWrapper folderFeedsWrapper, ) { - final unreadCount = feedsUnreadCountSum(folderFeedsWrapper.feeds); + final unreadCount = folderFeedsWrapper.feedsUnreadCountSum; return ListTile( title: Text( folderFeedsWrapper.folder.name,