From 7f702abc8a05c06ba79aa0948ade296eb5cdac97 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Wed, 24 Mar 2021 20:06:48 +0800 Subject: [PATCH 1/2] fixes build error --- Account/Sources/Account/Account.swift | 6 +++--- iOS/MasterFeed/MasterFeedViewController.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Account/Sources/Account/Account.swift b/Account/Sources/Account/Account.swift index 6b0cd940c..d82023c69 100644 --- a/Account/Sources/Account/Account.swift +++ b/Account/Sources/Account/Account.swift @@ -53,9 +53,9 @@ public enum AccountType: Int, Codable { } public enum FetchType { - case starred(Int?) - case unread(Int?) - case today(Int?) + case starred(_: Int? = nil) + case unread(_: Int? = nil) + case today(_: Int? = nil) case folder(Folder, Bool) case webFeed(WebFeed) case articleIDs(Set) diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index c2f719e6e..ee332f0a0 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -1235,7 +1235,7 @@ private extension MasterFeedViewController { let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, account.nameForDisplay) as String let action = UIAction(title: title, image: AppAssets.markAllAsReadImage) { [weak self] action in MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in - if let articles = try? account.fetchArticles(.unread) { + if let articles = try? account.fetchArticles(.unread()) { self?.coordinator.markAllAsRead(Array(articles)) } } From ca45ea6e0567857323ec9386aa6545a24e03df95 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Wed, 24 Mar 2021 20:30:21 +0800 Subject: [PATCH 2/2] Widget now uses limits --- Shared/Widget/WidgetDataEncoder.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Shared/Widget/WidgetDataEncoder.swift b/Shared/Widget/WidgetDataEncoder.swift index 5b928cea3..8a96d3737 100644 --- a/Shared/Widget/WidgetDataEncoder.swift +++ b/Shared/Widget/WidgetDataEncoder.swift @@ -12,11 +12,13 @@ import os.log import UIKit import RSCore import Articles +import Account public final class WidgetDataEncoder { private let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "Application") + private let fetchLimit = 7 private var backgroundTaskID: UIBackgroundTaskIdentifier! private lazy var appGroup = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as! String @@ -31,11 +33,9 @@ public final class WidgetDataEncoder { os_log(.debug, log: log, "Starting encoding widget data.") do { - let unreadArticles = Array(try SmartFeedsController.shared.unreadFeed.fetchArticles()).sortedByDate(.orderedDescending) - - let starredArticles = Array(try SmartFeedsController.shared.starredFeed.fetchArticles()).sortedByDate(.orderedDescending) - - let todayArticles = Array(try SmartFeedsController.shared.todayFeed.fetchUnreadArticles()).sortedByDate(.orderedDescending) + let unreadArticles = Array(try AccountManager.shared.fetchArticles(.unread(fetchLimit))).sortedByDate(.orderedDescending) + let starredArticles = Array(try AccountManager.shared.fetchArticles(.starred(fetchLimit))).sortedByDate(.orderedDescending) + let todayArticles = Array(try AccountManager.shared.fetchArticles(.today(fetchLimit))).sortedByDate(.orderedDescending) var unread = [LatestArticle]() var today = [LatestArticle]() @@ -74,9 +74,9 @@ public final class WidgetDataEncoder { if today.count == 7 { break } } - let latestData = WidgetData(currentUnreadCount: SmartFeedsController.shared.unreadFeed.unreadCount, - currentTodayCount: try! SmartFeedsController.shared.todayFeed.fetchUnreadArticles().count, - currentStarredCount: try! SmartFeedsController.shared.starredFeed.fetchArticles().count, + let latestData = WidgetData(currentUnreadCount: try! AccountManager.shared.fetchArticles(.unread()).count, + currentTodayCount: try! AccountManager.shared.fetchArticles(.today()).count, + currentStarredCount: try! AccountManager.shared.fetchArticles(.starred()).count, unreadArticles: unread, starredArticles: starred, todayArticles:today,