Use appDelegate’s coalescing queue for reloading visible cells.

This commit is contained in:
Brent Simmons 2018-02-17 15:16:30 -08:00
parent d1137b7192
commit 7bcb8f7d12
1 changed files with 2 additions and 17 deletions

View File

@ -57,7 +57,6 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
}
private var didRegisterForNotifications = false
private var reloadAvailableCellsTimer: Timer?
private var fetchAndMergeArticlesTimer: Timer?
private var sortDirection = AppDefaults.shared.timelineSortDirection {
@ -583,7 +582,7 @@ extension TimelineViewController: NSTableViewDelegate {
private extension TimelineViewController {
func reloadAvailableCells() {
@objc func reloadAvailableCells() {
if let indexesToReload = tableView.indexesOfAvailableRows() {
reloadCells(for: indexesToReload)
@ -592,21 +591,7 @@ private extension TimelineViewController {
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
}
appDelegate.coalescingQueue.add(self, #selector(reloadAvailableCells))
}
func updateTableViewRowHeight() {