From 1ca0df67a4adfa2457170c06c0a2398f21122487 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Fri, 26 Mar 2021 11:36:20 +0800 Subject: [PATCH] widget and unread badge counts are correct also - counts in the widget revert back to using data available in the SmartFeedsController. --- Shared/Widget/WidgetDataEncoder.swift | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Shared/Widget/WidgetDataEncoder.swift b/Shared/Widget/WidgetDataEncoder.swift index 8a96d3737..86c46be3b 100644 --- a/Shared/Widget/WidgetDataEncoder.swift +++ b/Shared/Widget/WidgetDataEncoder.swift @@ -49,7 +49,6 @@ public final class WidgetDataEncoder { feedIcon: article.iconImage()?.image.dataRepresentation(), pubDate: article.datePublished?.description ?? "") unread.append(latestArticle) - if unread.count == 7 { break } } for article in starredArticles { @@ -60,7 +59,6 @@ public final class WidgetDataEncoder { feedIcon: article.iconImage()?.image.dataRepresentation(), pubDate: article.datePublished?.description ?? "") starred.append(latestArticle) - if starred.count == 7 { break } } for article in todayArticles { @@ -71,12 +69,11 @@ public final class WidgetDataEncoder { feedIcon: article.iconImage()?.image.dataRepresentation(), pubDate: article.datePublished?.description ?? "") today.append(latestArticle) - if today.count == 7 { break } } - let latestData = WidgetData(currentUnreadCount: try! AccountManager.shared.fetchArticles(.unread()).count, - currentTodayCount: try! AccountManager.shared.fetchArticles(.today()).count, - currentStarredCount: try! AccountManager.shared.fetchArticles(.starred()).count, + let latestData = WidgetData(currentUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount, + currentTodayCount: SmartFeedsController.shared.todayFeed.unreadCount, + currentStarredCount: try! SmartFeedsController.shared.starredFeed.fetchArticles().count, unreadArticles: unread, starredArticles: starred, todayArticles:today,