Skip to content

Commit

Permalink
Move FaviconService (#23905)
Browse files Browse the repository at this point in the history
  • Loading branch information
kean authored Dec 18, 2024
1 parent 0e5b61f commit 2f334e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import UIKit

// Fetches URLs for favicons for sites.
actor FaviconService {
static let shared = FaviconService()
/// Fetches URLs for favicons for sites.
public actor FaviconService {
public static let shared = FaviconService()

private nonisolated let cache = FaviconCache()

Expand All @@ -14,12 +14,12 @@ actor FaviconService {

private var tasks: [URL: FaviconTask] = [:]

nonisolated func cachedFavicon(forURL siteURL: URL) -> URL? {
nonisolated public func cachedFavicon(forURL siteURL: URL) -> URL? {
cache.cachedFavicon(forURL: siteURL)
}

/// Returns a favicon URL for the given site.
func favicon(forURL siteURL: URL) async throws -> URL {
public func favicon(forURL siteURL: URL) async throws -> URL {
if let faviconURL = cache.cachedFavicon(forURL: siteURL) {
return faviconURL
}
Expand Down Expand Up @@ -57,7 +57,7 @@ actor FaviconService {
}
}

enum FaviconError: Error {
public enum FaviconError: Error, Sendable {
case unacceptableStatusCode(_ code: Int)
}

Expand Down Expand Up @@ -105,7 +105,7 @@ private final class FaviconTask {
var isCancelled = false
var task: Task<URL, Error>

init(_ closure: @escaping () async throws -> URL) {
init(_ closure: @escaping @Sendable () async throws -> URL) {
self.task = Task { try await closure() }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressMedia

final class ReaderPostCellViewModel {
// Header
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import WordPressMedia

struct ReaderSiteIconView: View, Hashable {
let site: ReaderSiteTopic
Expand Down

0 comments on commit 2f334e2

Please sign in to comment.