mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-01 09:50:16 +00:00
Make icon again when server replaces an image.
This commit is contained in:
1 parent
fc2e1eb53d
commit
93a011fb5c
1 file changed
+12
@@ -62,6 +62,7 @@ extension ImageDownloadError: LocalizedError {
|
||||
private init() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleAppDidGoToBackground(_:)), name: .appDidGoToBackground, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleLowMemory(_:)), name: .lowMemory, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleDownloadedImageDidChange(_:)), name: .downloadedImageDidChange, object: nil)
|
||||
}
|
||||
|
||||
@objc func handleAppDidGoToBackground(_ notification: Notification) {
|
||||
@@ -72,6 +73,17 @@ extension ImageDownloadError: LocalizedError {
|
||||
imageCache.removeAllObjects()
|
||||
}
|
||||
|
||||
/// Made again even when not in memory, since icons made from the old copy may be cached elsewhere.
|
||||
@objc func handleDownloadedImageDidChange(_ notification: Notification) {
|
||||
guard let url = notification.userInfo?[DownloadedImageCache.urlKey] as? String else {
|
||||
return
|
||||
}
|
||||
imageCache.removeObject(forKey: url as NSString)
|
||||
Task { @MainActor in
|
||||
await findImage(url, activityOwner: nil, activityKind: nil, activityDetail: nil)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the data if in memory, else makes it from `DownloadedImageCache`’s copy and returns nil.
|
||||
/// Posts `.imageDidBecomeAvailable` when it’s ready.
|
||||
/// Activity log fires only when the fetch reaches the network.
|
||||
|
||||
Reference in new issue
Block a user