mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-24 16:51:19 +01:00
Move undoable commands into TimelineViewController private extension.
This commit is contained in:
parent
b2ad739caf
commit
0960477be6
@ -121,31 +121,9 @@ class TimelineViewController: NSViewController, KeyboardDelegate {
|
||||
runCommand(markReadCommand)
|
||||
}
|
||||
|
||||
// MARK: - Undoable Commands
|
||||
func canMarkAllAsRead() -> Bool {
|
||||
|
||||
private func runCommand(_ undoableCommand: UndoableCommand) {
|
||||
|
||||
pushUndoableCommand(undoableCommand)
|
||||
undoableCommand.perform()
|
||||
}
|
||||
|
||||
private func pushUndoableCommand(_ undoableCommand: UndoableCommand) {
|
||||
|
||||
undoableCommands += [undoableCommand]
|
||||
}
|
||||
|
||||
private func clearUndoableCommands() {
|
||||
|
||||
// When the timeline is reloaded and the list of articles changes,
|
||||
// undoable commands should be dropped — otherwise things like
|
||||
// Redo Mark 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]()
|
||||
return articles.canMarkAllAsRead()
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
@ -199,7 +177,6 @@ class TimelineViewController: NSViewController, KeyboardDelegate {
|
||||
}
|
||||
tableView.rs_selectRow(ix)
|
||||
tableView.scrollTo(row: ix)
|
||||
// tableView.rs_selectRowAndScrollToVisible(ix)
|
||||
}
|
||||
|
||||
func canGoToNextUnread() -> Bool {
|
||||
@ -210,11 +187,6 @@ class TimelineViewController: NSViewController, KeyboardDelegate {
|
||||
return true
|
||||
}
|
||||
|
||||
func canMarkAllAsRead() -> Bool {
|
||||
|
||||
return articles.canMarkAllAsRead()
|
||||
}
|
||||
|
||||
func indexOfNextUnreadArticle() -> Int? {
|
||||
|
||||
return articles.rowOfNextUnreadArticle(tableView.selectedRow)
|
||||
@ -347,6 +319,36 @@ class TimelineViewController: NSViewController, KeyboardDelegate {
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Undoable Commands
|
||||
|
||||
private extension TimelineViewController {
|
||||
|
||||
func runCommand(_ undoableCommand: UndoableCommand) {
|
||||
|
||||
pushUndoableCommand(undoableCommand)
|
||||
undoableCommand.perform()
|
||||
}
|
||||
|
||||
func pushUndoableCommand(_ undoableCommand: UndoableCommand) {
|
||||
|
||||
undoableCommands += [undoableCommand]
|
||||
}
|
||||
|
||||
func clearUndoableCommands() {
|
||||
|
||||
// When the timeline is reloaded and the list of articles changes,
|
||||
// undoable commands should be dropped — otherwise things like
|
||||
// Redo Mark 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]()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - NSTableViewDataSource
|
||||
|
||||
extension TimelineViewController: NSTableViewDataSource {
|
||||
|
Loading…
Reference in New Issue
Block a user