diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index 454a14161..18d9c705d 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -27,7 +27,10 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView private var articles = [Article]() { didSet { - tableView.reloadData() + if articles != oldValue { + clearUndoableCommands() + tableView.reloadData() + } } } @@ -123,10 +126,16 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView guard let undoManager = undoManager, let markAllReadCommand = MarkAllReadCommand(initialArticles: articles, undoManager: undoManager) else { return } - markAllReadCommand.perform() + runCommand(markAllReadCommand) + } + + // MARK: - Undoable Commands + + private func runCommand(_ undoableCommand: UndoableCommand) { + + pushUndoableCommand(undoableCommand) + undoableCommand.perform() } - - // MARK: - Actions private func pushUndoableCommand(_ undoableCommand: UndoableCommand) { @@ -147,6 +156,8 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView undoableCommands = [UndoableCommand]() } + // MARK: - Actions + @objc func openArticleInBrowser(_ sender: AnyObject) { if let link = oneSelectedArticle?.preferredLink {