From b34510eb5c5d90fa6b49c6c7287b5580cd0bbc26 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Thu, 19 Nov 2020 20:21:04 +0800 Subject: [PATCH] changes the behaviour of the today widget --- Shared/Widget/WidgetDataEncoder.swift | 4 ++-- Widget/Localizable.stringsdict | 4 ++-- Widget/WidgetBundle.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Shared/Widget/WidgetDataEncoder.swift b/Shared/Widget/WidgetDataEncoder.swift index 6a177cc1d..171afbf28 100644 --- a/Shared/Widget/WidgetDataEncoder.swift +++ b/Shared/Widget/WidgetDataEncoder.swift @@ -50,7 +50,7 @@ struct WidgetDataEncoder { } // Today Articles - let todayArticles = try SmartFeedsController.shared.todayFeed.fetchArticles().sorted(by: { $0.datePublished ?? .distantPast > $1.datePublished ?? .distantPast }) + let todayArticles = try SmartFeedsController.shared.todayFeed.fetchArticles().sorted(by: { $0.datePublished ?? .distantPast > $1.datePublished ?? .distantPast }).filter({ $0.status.read == false }) var today = [LatestArticle]() for article in todayArticles { let latestArticle = LatestArticle(id: article.sortableArticleID, @@ -64,7 +64,7 @@ struct WidgetDataEncoder { } let latestData = WidgetData(currentUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount, - currentTodayCount: try! SmartFeedsController.shared.todayFeed.fetchArticles().count, + currentTodayCount: try! SmartFeedsController.shared.todayFeed.fetchArticles().filter({ $0.status.read == false }).count, currentStarredCount: try! SmartFeedsController.shared.starredFeed.fetchArticles().count, unreadArticles: unread, starredArticles: starred, diff --git a/Widget/Localizable.stringsdict b/Widget/Localizable.stringsdict index da0030943..367e1afb7 100644 --- a/Widget/Localizable.stringsdict +++ b/Widget/Localizable.stringsdict @@ -51,9 +51,9 @@ zero No more recent articles one - + 1 more recent article + + 1 more recent unread article other - + %u more recent articles + + %u more recent unread articles diff --git a/Widget/WidgetBundle.swift b/Widget/WidgetBundle.swift index 95cce7236..3ea531f53 100644 --- a/Widget/WidgetBundle.swift +++ b/Widget/WidgetBundle.swift @@ -41,7 +41,7 @@ struct TodayWidget: Widget { }) .configurationDisplayName("Your Today Articles") - .description("A sneak peak at recently published articles.") + .description("A sneak peak at unread recently published articles.") .supportedFamilies([.systemMedium, .systemLarge]) }