From d43ca5a228ad450eaa6ee2194c8fcd42688df304 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 7 Mar 2026 17:14:21 -0800 Subject: [PATCH] Handle low memory notification. --- Shared/Images/AuthorAvatarDownloader.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Shared/Images/AuthorAvatarDownloader.swift b/Shared/Images/AuthorAvatarDownloader.swift index 44cccbcf5..79dfd733e 100644 --- a/Shared/Images/AuthorAvatarDownloader.swift +++ b/Shared/Images/AuthorAvatarDownloader.swift @@ -11,12 +11,10 @@ import Articles import RSCore extension Notification.Name { - static let AvatarDidBecomeAvailable = Notification.Name("AvatarDidBecomeAvailableNotification") // UserInfoKey.imageURL (which is an avatarURL) } @MainActor final class AuthorAvatarDownloader { - public static let shared = AuthorAvatarDownloader() private let imageDownloader = ImageDownloader.shared @@ -24,12 +22,12 @@ extension Notification.Name { private var waitingForAvatarURLs = Set() init() { - NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .imageDidBecomeAvailable, object: imageDownloader) + NotificationCenter.default.addObserver(self, selector: #selector(handleLowMemory(_:)), name: .lowMemory, object: nil) } - func resetCache() { - cache = [String: IconImage]() + @objc func handleLowMemory(_ notification: Notification) { + cache.removeAll() } func image(for author: Author) -> IconImage? {