From ec8cfa91e8f8dd7e69fe6279933eebc3426ecd71 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 28 Apr 2024 22:26:25 -0700 Subject: [PATCH] Add addExistingFeed function to replace FeedlyAddExistingFeedOperation. --- .../AccountDelegates/FeedlyAccountDelegate.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift b/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift index 65503b133..ce3c98da3 100644 --- a/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift +++ b/Account/Sources/Account/AccountDelegates/FeedlyAccountDelegate.swift @@ -954,7 +954,7 @@ final class FeedlyAccountDelegate: AccountDelegate { try await updateAccountFeeds(parsedItems: parsedItems) } - func addNewFeed(url: String, feedName: String?) async throws { + func addNewFeed(url: String, feedName: String?, container: Container) async throws { // To replace FeedlyAddNewFeedOperation @@ -962,7 +962,7 @@ final class FeedlyAccountDelegate: AccountDelegate { let (folder, collectionID) = try validator.getValidContainer() let searchResponse = try await searchForFeed(url: url) - guard let firstFeed = response.results.first else { + guard let firstFeed = searchResponse.results.first else { throw AccountError.createErrorNotFound } let feedResourceID = FeedlyFeedResourceID(id: firstFeed.feedID) @@ -972,10 +972,20 @@ final class FeedlyAccountDelegate: AccountDelegate { // TODO: FeedlyCreateFeedsForCollectionFoldersOperation replacement // let createFeeds = TODO - try await fetchAndProcessUnreadArticleIDs() + //try await fetchAndProcessUnreadArticleIDs() // TODO try await syncStreamContents(feedResourceID: feedResourceID) } + func addExistingFeed(resourceID: FeedlyFeedResourceID, container: Container, customFeedName: String? = nil) async throws { + + // To replace FeedlyAddExistingFeedOperation + + let validator = FeedlyFeedContainerValidator(container: container) + let (folder, collectionID) = try validator.getValidContainer() + + try await addFeedToCollection(feedResource: resourceID, feedName: customFeedName, collectionID: collectionID, folder: folder) + } + // MARK: Suspend and Resume (for iOS) /// Suspend all network activity