mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-20 14:33:04 +01:00
Make feed icons show up more promptly and reliably in the timeline.
This commit is contained in:
parent
6d94372eef
commit
1b0648cd18
@ -131,6 +131,8 @@ private extension ImageDownloader {
|
|||||||
|
|
||||||
func postImageDidBecomeAvailableNotification(_ url: String) {
|
func postImageDidBecomeAvailableNotification(_ url: String) {
|
||||||
|
|
||||||
NotificationCenter.default.post(name: .ImageDidBecomeAvailable, object: self, userInfo: [UserInfoKey.url: url])
|
DispatchQueue.main.async {
|
||||||
|
NotificationCenter.default.post(name: .ImageDidBecomeAvailable, object: self, userInfo: [UserInfoKey.url: url])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
|||||||
|
|
||||||
private var didRegisterForNotifications = false
|
private var didRegisterForNotifications = false
|
||||||
private let timelineFontSizeKVOKey = "values.{AppDefaults.Key.timelineFontSize}"
|
private let timelineFontSizeKVOKey = "values.{AppDefaults.Key.timelineFontSize}"
|
||||||
|
private var reloadAvailableCellsTimer: Timer?
|
||||||
|
|
||||||
private var articles = ArticleArray() {
|
private var articles = ArticleArray() {
|
||||||
didSet {
|
didSet {
|
||||||
@ -117,6 +118,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(feedIconDidBecomeAvailable(_:)), name: .FeedIconDidBecomeAvailable, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(feedIconDidBecomeAvailable(_:)), name: .FeedIconDidBecomeAvailable, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(avatarDidBecomeAvailable(_:)), name: .AvatarDidBecomeAvailable, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(avatarDidBecomeAvailable(_:)), name: .AvatarDidBecomeAvailable, object: nil)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .ImageDidBecomeAvailable, object: nil)
|
||||||
|
|
||||||
NSUserDefaultsController.shared.addObserver(self, forKeyPath: timelineFontSizeKVOKey, options: NSKeyValueObservingOptions(rawValue: 0), context: nil)
|
NSUserDefaultsController.shared.addObserver(self, forKeyPath: timelineFontSizeKVOKey, options: NSKeyValueObservingOptions(rawValue: 0), context: nil)
|
||||||
|
|
||||||
@ -347,6 +349,11 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func imageDidBecomeAvailable(_ note: Notification) {
|
||||||
|
|
||||||
|
queueReloadAvailableCells()
|
||||||
|
}
|
||||||
|
|
||||||
func fontSizeInDefaultsDidChange() {
|
func fontSizeInDefaultsDidChange() {
|
||||||
|
|
||||||
TimelineCellData.emptyCache()
|
TimelineCellData.emptyCache()
|
||||||
@ -554,6 +561,32 @@ extension TimelineViewController: NSTableViewDelegate {
|
|||||||
|
|
||||||
private extension TimelineViewController {
|
private extension TimelineViewController {
|
||||||
|
|
||||||
|
func reloadAvailableCells() {
|
||||||
|
|
||||||
|
if let indexesToReload = tableView.indexesOfAvailableRows() {
|
||||||
|
reloadCells(for: indexesToReload)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func queueReloadAvailableCells() {
|
||||||
|
|
||||||
|
invalidateReloadTimer()
|
||||||
|
reloadAvailableCellsTimer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: false) { (timer) in
|
||||||
|
self.reloadAvailableCells()
|
||||||
|
self.invalidateReloadTimer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func invalidateReloadTimer() {
|
||||||
|
|
||||||
|
if let timer = reloadAvailableCellsTimer {
|
||||||
|
if timer.isValid {
|
||||||
|
timer.invalidate()
|
||||||
|
}
|
||||||
|
reloadAvailableCellsTimer = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func updateShowAvatars() {
|
func updateShowAvatars() {
|
||||||
|
|
||||||
if showFeedNames {
|
if showFeedNames {
|
||||||
|
@ -30,6 +30,13 @@ public extension NSTableView {
|
|||||||
return indexes.isEmpty ? nil : indexes
|
return indexes.isEmpty ? nil : indexes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func indexesOfAvailableRows() -> IndexSet? {
|
||||||
|
|
||||||
|
var indexes = IndexSet()
|
||||||
|
enumerateAvailableRowViews { indexes.insert($1) }
|
||||||
|
return indexes.isEmpty ? nil : indexes
|
||||||
|
}
|
||||||
|
|
||||||
func scrollTo(row: Int) {
|
func scrollTo(row: Int) {
|
||||||
|
|
||||||
guard let scrollView = self.enclosingScrollView else {
|
guard let scrollView = self.enclosingScrollView else {
|
||||||
|
Loading…
Reference in New Issue
Block a user