Implement more keyboard shortcuts

This commit is contained in:
Maurice Parker 2019-09-05 14:50:05 -05:00
parent 73828e5115
commit 7582ade6f5
2 changed files with 25 additions and 0 deletions

View File

@ -26,21 +26,29 @@ class RootSplitViewController: UISplitViewController {
}
@objc func nextUnread(_ sender: Any?) {
coordinator.selectNextUnread()
}
@objc func markRead(_ sender: Any?) {
coordinator.markAsReadForCurrentArticle()
}
@objc func markUnreadAndGoToNextUnread(_ sender: Any?) {
coordinator.markAsUnreadForCurrentArticle()
coordinator.selectNextUnread()
}
@objc func markAllAsReadAndGoToNextUnread(_ sender: Any?) {
coordinator.markAllAsReadInTimeline()
coordinator.selectNextUnread()
}
@objc func markOlderArticlesAsRead(_ sender: Any?) {
coordinator.markAsReadOlderArticlesInTimeline()
}
@objc func markUnread(_ sender: Any?) {
coordinator.markAsUnreadForCurrentArticle()
}
@objc func goToPreviousSubscription(_ sender: Any?) {

View File

@ -731,6 +731,11 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
masterNavigationController.popViewController(animated: true)
}
func markAsReadOlderArticlesInTimeline() {
if let indexPath = currentArticleIndexPath {
markAsReadOlderArticlesInTimeline(indexPath)
}
}
func markAsReadOlderArticlesInTimeline(_ indexPath: IndexPath) {
let article = articles[indexPath.row]
let articlesToMark = articles.filter { $0.logicalDatePublished < article.logicalDatePublished }
@ -740,6 +745,18 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
markAllAsRead(articlesToMark)
}
func markAsReadForCurrentArticle() {
if let article = currentArticle {
markArticles(Set([article]), statusKey: .read, flag: true)
}
}
func markAsUnreadForCurrentArticle() {
if let article = currentArticle {
markArticles(Set([article]), statusKey: .read, flag: false)
}
}
func toggleReadForCurrentArticle() {
if let article = currentArticle {
markArticles(Set([article]), statusKey: .read, flag: !article.status.read)