Browse Source

neon_news: make feedsUnreadCountSum a property of FolderFeedsWrapper

pull/380/head
Nikolas Rimikis 2 years ago
parent
commit
7fa3a8e6f5
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 5
      packages/neon/neon_news/lib/sort/folders.dart
  2. 2
      packages/neon/neon_news/lib/widgets/folders_view.dart

5
packages/neon/neon_news/lib/sort/folders.dart

@ -3,7 +3,7 @@ part of '../neon_news.dart';
final foldersSortBox = SortBox<FoldersSortProperty, FolderFeedsWrapper>(
{
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<NextcloudNewsFeed> feeds;
int get feedsUnreadCountSum => feeds.fold(0, (final a, final b) => a + b.unreadCount!);
}
int feedsUnreadCountSum(final List<NextcloudNewsFeed> feeds) => feeds.fold(0, (final a, final b) => a + b.unreadCount!);

2
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,

Loading…
Cancel
Save