Mark FaviconDownloader as MainActor.

This commit is contained in:
Brent Simmons 2024-04-07 21:33:53 -07:00
parent d1dc4cceec
commit a31f59670b

View File

@ -18,7 +18,7 @@ extension Notification.Name {
static let FaviconDidBecomeAvailable = Notification.Name("FaviconDidBecomeAvailableNotification") // userInfo key: FaviconDownloader.UserInfoKey.faviconURL static let FaviconDidBecomeAvailable = Notification.Name("FaviconDidBecomeAvailableNotification") // userInfo key: FaviconDownloader.UserInfoKey.faviconURL
} }
final class FaviconDownloader { @MainActor final class FaviconDownloader {
private static let saveQueue = CoalescingQueue(name: "Cache Save Queue", interval: 1.0) private static let saveQueue = CoalescingQueue(name: "Cache Save Queue", interval: 1.0)
@ -71,7 +71,7 @@ final class FaviconDownloader {
cache = [Feed: IconImage]() cache = [Feed: IconImage]()
} }
@MainActor func favicon(for feed: Feed) -> IconImage? { func favicon(for feed: Feed) -> IconImage? {
assert(Thread.isMainThread) assert(Thread.isMainThread)
@ -93,7 +93,7 @@ final class FaviconDownloader {
return nil return nil
} }
@MainActor func faviconAsIcon(for feed: Feed) -> IconImage? { func faviconAsIcon(for feed: Feed) -> IconImage? {
if let image = cache[feed] { if let image = cache[feed] {
return image return image
@ -199,7 +199,7 @@ private extension FaviconDownloader {
static let localeForLowercasing = Locale(identifier: "en_US") static let localeForLowercasing = Locale(identifier: "en_US")
@MainActor func findFaviconURLs(with homePageURL: String, _ completion: @escaping ([String]?) -> Void) { func findFaviconURLs(with homePageURL: String, _ completion: @escaping ([String]?) -> Void) {
guard let url = URL(unicodeString: homePageURL) else { guard let url = URL(unicodeString: homePageURL) else {
completion(nil) completion(nil)
@ -318,5 +318,4 @@ private extension FaviconDownloader {
assertionFailure(error.localizedDescription) assertionFailure(error.localizedDescription)
} }
} }
} }