From bb5099c3a502a75de97e20a689e162fbaf3d8cbf Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 29 Apr 2024 13:23:17 -0700 Subject: [PATCH] Create fetchRemoteArticleIDs to use as common code for fetchRemoteStarredArticleIDs and fetchRemoteUnreadArticleIDs. --- .../FeedlyAccountDelegate.swift | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift b/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift index e2df21b58..09367a6e6 100644 --- a/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift +++ b/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift @@ -839,15 +839,13 @@ final class FeedlyAccountDelegate: AccountDelegate { return try await account.fetchArticleIDsForStatusesWithoutArticlesNewerThanCutoffDate() } - func fetchRemoteStarredArticleIDs() async throws -> Set { + func fetchRemoteArticleIDs(resource: FeedlyResourceID, unreadOnly: Bool? = nil) async throws -> Set { - guard let userID else { return Set() } - - let resource = FeedlyTagResourceID.Global.saved(for: userID) var remoteArticleIDs = Set() func fetchIDs(_ continuation: String? = nil) async throws { - let streamIDs = try await caller.getStreamIDs(for: resource, continuation: continuation, newerThan: nil, unreadOnly: nil) + + let streamIDs = try await caller.getStreamIDs(for: resource, continuation: continuation, newerThan: nil, unreadOnly: unreadOnly) remoteArticleIDs.formUnion(streamIDs.ids) guard let continuation = streamIDs.continuation else { // finished fetching article IDs? @@ -861,6 +859,22 @@ final class FeedlyAccountDelegate: AccountDelegate { return remoteArticleIDs } + func fetchRemoteUnreadArticleIDs() async throws -> Set { + + guard let userID else { return Set() } + + let resource = FeedlyCategoryResourceID.Global.all(for: userID) + return try await fetchRemoteArticleIDs(resource: resource, unreadOnly: true) + } + + func fetchRemoteStarredArticleIDs() async throws -> Set { + + guard let userID else { return Set() } + + let resource = FeedlyTagResourceID.Global.saved(for: userID) + return try await fetchRemoteArticleIDs(resource: resource) + } + func processStarredArticleIDs(remoteArticleIDs: Set) async throws { guard let account else { return }