Create searchForFeed function which will replace FeedlySearchOperation.
This commit is contained in:
parent
9b8bb4b158
commit
7946983bca
@ -798,6 +798,13 @@ final class FeedlyAccountDelegate: AccountDelegate {
|
|||||||
os_log(.debug, log: self.log, "Done sending article statuses.")
|
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)
|
// MARK: Suspend and Resume (for iOS)
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ extension FeedlyAPICaller: FeedlyMarkArticlesService {
|
|||||||
|
|
||||||
extension FeedlyAPICaller: FeedlySearchService {
|
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 }
|
guard !isSuspended else { throw TransportError.suspended }
|
||||||
|
|
||||||
@ -544,7 +544,7 @@ extension FeedlyAPICaller: FeedlySearchService {
|
|||||||
components.queryItems = [
|
components.queryItems = [
|
||||||
URLQueryItem(name: "query", value: query),
|
URLQueryItem(name: "query", value: query),
|
||||||
URLQueryItem(name: "count", value: String(count)),
|
URLQueryItem(name: "count", value: String(count)),
|
||||||
URLQueryItem(name: "locale", value: locale)
|
URLQueryItem(name: "locale", value: localeIdentifier)
|
||||||
]
|
]
|
||||||
guard let url = components.url else {
|
guard let url = components.url else {
|
||||||
fatalError("\(components) does not produce a valid URL.")
|
fatalError("\(components) does not produce a valid URL.")
|
||||||
|
@ -85,7 +85,7 @@ final class FeedlyAddNewFeedOperation: FeedlyOperation, FeedlyOperationDelegate,
|
|||||||
return didFinish(with: AccountError.createErrorNotFound)
|
return didFinish(with: AccountError.createErrorNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
let feedResourceID = FeedlyFeedResourceID(id: first.feedId)
|
let feedResourceID = FeedlyFeedResourceID(id: first.feedID)
|
||||||
self.feedResourceID = feedResourceID
|
self.feedResourceID = feedResourceID
|
||||||
|
|
||||||
let addRequest = FeedlyAddFeedToCollectionOperation(folder: folder, feedResource: feedResourceID, feedName: feedName, collectionID: collectionID, service: addToCollectionService)
|
let addRequest = FeedlyAddFeedToCollectionOperation(folder: folder, feedResource: feedResourceID, feedName: feedName, collectionID: collectionID, service: addToCollectionService)
|
||||||
|
@ -298,7 +298,7 @@ public struct FeedlyFeedsSearchResponse: Decodable, Sendable {
|
|||||||
public struct Feed: Decodable, Sendable {
|
public struct Feed: Decodable, Sendable {
|
||||||
|
|
||||||
public let title: String
|
public let title: String
|
||||||
public let feedId: String
|
public let feedID: String
|
||||||
}
|
}
|
||||||
|
|
||||||
public let results: [Feed]
|
public let results: [Feed]
|
||||||
|
@ -10,7 +10,7 @@ import Foundation
|
|||||||
|
|
||||||
public protocol FeedlySearchService: AnyObject {
|
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 {
|
public protocol FeedlySearchOperationDelegate: AnyObject {
|
||||||
@ -38,7 +38,7 @@ public final class FeedlySearchOperation: FeedlyOperation {
|
|||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
|
|
||||||
do {
|
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.searchDelegate?.feedlySearchOperation(self, didGet: searchResponse)
|
||||||
self.didFinish()
|
self.didFinish()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user