mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-09 00:28:53 +01:00
Add row swipe action for Mark/Unmark Starred
This commit is contained in:
parent
bc32fc1cb9
commit
f67b7df5a9
@ -754,20 +754,38 @@ extension TimelineViewController: NSTableViewDelegate {
|
|||||||
self.runCommand(markUnreadCommand)
|
self.runCommand(markUnreadCommand)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func toggleArticleStarred(_ article: Article) {
|
||||||
|
guard let undoManager = undoManager, let markUnreadCommand = MarkStatusCommand(initialArticles: [article], markingStarred: !article.status.starred, undoManager: undoManager) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.runCommand(markUnreadCommand)
|
||||||
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
|
func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
|
||||||
|
|
||||||
if edge == .leading {
|
guard let article = articles.articleAtRow(row) else {
|
||||||
guard let article = articles.articleAtRow(row) else {
|
return []
|
||||||
return []
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let title = article.status.read ? NSLocalizedString("Mark Unread", comment: "mark unread") : NSLocalizedString("Mark Read", comment: "mark read")
|
switch edge {
|
||||||
|
case .leading:
|
||||||
|
let title = article.status.read ? NSLocalizedString("Mark Unread", comment: "mark unread") : NSLocalizedString("Mark Read", comment: "mark read")
|
||||||
|
let action = NSTableViewRowAction(style: .regular, title: title) { (action, row) in
|
||||||
|
self.toggleArticleRead(article);
|
||||||
|
tableView.rowActionsVisible = false
|
||||||
|
}
|
||||||
|
return [action]
|
||||||
|
|
||||||
let action = NSTableViewRowAction(style: .regular, title: title) { (action, row) in
|
case .trailing:
|
||||||
self.toggleArticleRead(article);
|
let title = article.status.starred ? NSLocalizedString("Mark Unstarred", comment: "mark unstarred") : NSLocalizedString("Mark Starred", comment: "mark starred")
|
||||||
tableView.rowActionsVisible = false
|
let action = NSTableViewRowAction(style: .regular, title: title) { (action, row) in
|
||||||
}
|
self.toggleArticleStarred(article);
|
||||||
return [action]
|
tableView.rowActionsVisible = false
|
||||||
|
}
|
||||||
|
return [action]
|
||||||
|
|
||||||
|
@unknown default:
|
||||||
|
NSLog("Unknown table row edge: %ld", edge.rawValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user