mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 08:42:51 +00:00
Handle low memory notification.
This commit is contained in:
1 parent
a760d30cd3
commit
d43ca5a228
1 file changed
+3
-5
@@ -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<String>()
|
||||
|
||||
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? {
|
||||
|
||||
Reference in new issue
Block a user