mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-20 14:33:04 +01:00
Begin support for clearing undo commands on sidebar selection change.
This commit is contained in:
parent
f9b3eeb4d7
commit
5f848f568a
@ -16,6 +16,7 @@ import Account
|
|||||||
class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource, KeyboardDelegate {
|
class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableViewDataSource, KeyboardDelegate {
|
||||||
|
|
||||||
@IBOutlet var tableView: TimelineTableView!
|
@IBOutlet var tableView: TimelineTableView!
|
||||||
|
private var undoableCommands = [UndoableCommand]()
|
||||||
var didRegisterForNotifications = false
|
var didRegisterForNotifications = false
|
||||||
var fontSize: FontSize = AppDefaults.shared.timelineFontSize {
|
var fontSize: FontSize = AppDefaults.shared.timelineFontSize {
|
||||||
didSet {
|
didSet {
|
||||||
@ -127,6 +128,25 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
|
|||||||
|
|
||||||
// MARK: - Actions
|
// MARK: - Actions
|
||||||
|
|
||||||
|
private func pushUndoableCommand(_ undoableCommand: UndoableCommand) {
|
||||||
|
|
||||||
|
undoableCommands += [undoableCommand]
|
||||||
|
}
|
||||||
|
|
||||||
|
private func clearUndoableCommands() {
|
||||||
|
|
||||||
|
// When the timeline is reloaded based on a different sidebar selection,
|
||||||
|
// undoable commands should be dropped — otherwise things like
|
||||||
|
// Redo Mark All as Read are ambiguous. (Do they apply to the previous articles
|
||||||
|
// or to the current articles?)
|
||||||
|
|
||||||
|
guard let undoManager = undoManager else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
undoableCommands.forEach { undoManager.removeAllActions(withTarget: $0) }
|
||||||
|
undoableCommands = [UndoableCommand]()
|
||||||
|
}
|
||||||
|
|
||||||
@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
Block a user