Clear undoableCommands when the articles array changes.
This commit is contained in:
parent
5f848f568a
commit
9fbce42959
|
@ -27,7 +27,10 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
||||||
|
|
||||||
private var articles = [Article]() {
|
private var articles = [Article]() {
|
||||||
didSet {
|
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 {
|
guard let undoManager = undoManager, let markAllReadCommand = MarkAllReadCommand(initialArticles: articles, undoManager: undoManager) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
markAllReadCommand.perform()
|
runCommand(markAllReadCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Undoable Commands
|
||||||
|
|
||||||
|
private func runCommand(_ undoableCommand: UndoableCommand) {
|
||||||
|
|
||||||
|
pushUndoableCommand(undoableCommand)
|
||||||
|
undoableCommand.perform()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Actions
|
|
||||||
|
|
||||||
private func pushUndoableCommand(_ undoableCommand: UndoableCommand) {
|
private func pushUndoableCommand(_ undoableCommand: UndoableCommand) {
|
||||||
|
|
||||||
|
@ -147,6 +156,8 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
||||||
undoableCommands = [UndoableCommand]()
|
undoableCommands = [UndoableCommand]()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Actions
|
||||||
|
|
||||||
@objc func openArticleInBrowser(_ sender: AnyObject) {
|
@objc func openArticleInBrowser(_ sender: AnyObject) {
|
||||||
|
|
||||||
if let link = oneSelectedArticle?.preferredLink {
|
if let link = oneSelectedArticle?.preferredLink {
|
||||||
|
|
Loading…
Reference in New Issue