Create searchForFeed function which will replace FeedlySearchOperation.

This commit is contained in:
Brent Simmons 2024-04-28 13:00:19 -07:00
parent 9b8bb4b158
commit 7946983bca
5 changed files with 13 additions and 6 deletions

View File

@ -798,6 +798,13 @@ final class FeedlyAccountDelegate: AccountDelegate {
os_log(.debug, log: self.log, "Done sending article statuses.")
}
func searchForFeed(url: String) async throws -> FeedlyFeedsSearchResponse {
// To replace FeedlySearchOperation
try await caller.getFeeds(for: url, count: 1, localeIdentifier: Locale.current.identifier)
}
// MARK: Suspend and Resume (for iOS)

View File

@ -535,7 +535,7 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService {
extension FeedlyAPICaller: FeedlySearchService {
func getFeeds(for query: String, count: Int, locale: String) async throws -> FeedlyFeedsSearchResponse {
func getFeeds(for query: String, count: Int, localeIdentifier: String) async throws -> FeedlyFeedsSearchResponse {
guard !isSuspended else { throw TransportError.suspended }
@ -544,7 +544,7 @@ extension FeedlyAPICaller: FeedlySearchService {
components.queryItems = [
URLQueryItem(name: "query", value: query),
URLQueryItem(name: "count", value: String(count)),
URLQueryItem(name: "locale", value: locale)
URLQueryItem(name: "locale", value: localeIdentifier)
]
guard let url = components.url else {
fatalError("\(components) does not produce a valid URL.")

View File

@ -85,7 +85,7 @@ final class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate,
return didFinish(with: AccountError.createErrorNotFound)
}
let feedResourceID = FeedlyFeedResourceID(id: first.feedId)
let feedResourceID = FeedlyFeedResourceID(id: first.feedID)
self.feedResourceID = feedResourceID
let addRequest = FeedlyAddFeedToCollectionOperation(folder: folder, feedResource: feedResourceID, feedName: feedName, collectionID: collectionID, service: addToCollectionService)

View File

@ -298,7 +298,7 @@ public struct FeedlyFeedsSearchResponse: Decodable, Sendable {
public struct Feed: Decodable, Sendable {
public let title: String
public let feedId: String
public let feedID: String
}
public let results: [Feed]

View File

@ -10,7 +10,7 @@ import Foundation
public protocol FeedlySearchService: AnyObject {
@MainActor func getFeeds(for query: String, count: Int, locale: String) async throws -> FeedlyFeedsSearchResponse
@MainActor func getFeeds(for query: String, count: Int, localeIdentifier: String) async throws -> FeedlyFeedsSearchResponse
}
public protocol FeedlySearchOperationDelegate: AnyObject {
@ -38,7 +38,7 @@ public final class FeedlySearchOperation: FeedlyOperation {
Task { @MainActor in
do {
let searchResponse = try await searchService.getFeeds(for: query, count: 1, locale: locale.identifier)
let searchResponse = try await searchService.getFeeds(for: query, count: 1, localeIdentifier: locale.identifier)
self.searchDelegate?.feedlySearchOperation(self, didGet: searchResponse)
self.didFinish()