From 7582ade6f546ab548c61498ece3d3c7a6b615b8f Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 5 Sep 2019 14:50:05 -0500 Subject: [PATCH] Implement more keyboard shortcuts --- iOS/RootSplitViewController.swift | 8 ++++++++ iOS/SceneCoordinator.swift | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index d5726eaa0..278e0c6a7 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -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?) { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 40cca25c8..b6519fa4e 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -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)