Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move FaviconService to WordPressMedia and make it compatible with Swift 6 #23905

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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