diff --git a/iOS/KeyboardManager.swift b/iOS/KeyboardManager.swift index 3c68dd119..7d11931b2 100644 --- a/iOS/KeyboardManager.swift +++ b/iOS/KeyboardManager.swift @@ -139,13 +139,19 @@ private extension KeyboardManager { keys.append(KeyboardManager.createKeyCommand(title: goToStarredTitle, action: "goToStarred:", input: "3", modifiers: [.command])) let articleSearchTitle = NSLocalizedString("Article Search", comment: "Article Search") - keys.append(KeyboardManager.createKeyCommand(title: articleSearchTitle, action: "articleSearch:", input: "f", modifiers: [.command, .shift])) + keys.append(KeyboardManager.createKeyCommand(title: articleSearchTitle, action: "articleSearch:", input: "f", modifiers: [.command, .alternate])) let markAllAsReadTitle = NSLocalizedString("Mark All as Read", comment: "Mark All as Read") keys.append(KeyboardManager.createKeyCommand(title: markAllAsReadTitle, action: "markAllAsRead:", input: "k", modifiers: [.command])) let cleanUp = NSLocalizedString("Clean Up", comment: "Clean Up") - keys.append(KeyboardManager.createKeyCommand(title: cleanUp, action: "cleanUp:", input: "h", modifiers: [.command, .shift])) + keys.append(KeyboardManager.createKeyCommand(title: cleanUp, action: "cleanUp:", input: "`", modifiers: [.command])) + + let toggleReadFeedsFilter = NSLocalizedString("Toggle Read Feeds Filter", comment: "Toggle Read Feeds Filter") + keys.append(KeyboardManager.createKeyCommand(title: toggleReadFeedsFilter, action: "toggleReadFeedsFilter:", input: "f", modifiers: [.command, .shift])) + + let toggleReadArticlesFilter = NSLocalizedString("Toggle Read Articles Filter", comment: "Toggle Read Articles Filter") + keys.append(KeyboardManager.createKeyCommand(title: toggleReadArticlesFilter, action: "toggleReadArticlesFilter:", input: "h", modifiers: [.command, .shift])) return keys } diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 89b4895ec..5432c72a0 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -378,13 +378,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { } @IBAction func toggleFilter(_ sender: Any) { - if coordinator.isReadFeedsFiltered { - setFilterButtonToInactive() - coordinator.showAllFeeds() - } else { - setFilterButtonToActive() - coordinator.hideReadFeeds() - } + coordinator.toggleReadFeedsFilter() } @IBAction func add(_ sender: UIBarButtonItem) { @@ -509,6 +503,16 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { } } + func updateUI() { + if coordinator.isReadFeedsFiltered { + setFilterButtonToActive() + } else { + setFilterButtonToInactive() + } + refreshProgressView?.updateRefreshLabel() + addNewItemButton?.isEnabled = !AccountManager.shared.activeAccounts.isEmpty + } + func focus() { becomeFirstResponder() } @@ -580,16 +584,6 @@ private extension MasterFeedViewController { toolbarItems?.insert(refreshProgressItemButton, at: 2) } - func updateUI() { - if coordinator.isReadFeedsFiltered { - setFilterButtonToActive() - } else { - setFilterButtonToInactive() - } - refreshProgressView?.updateRefreshLabel() - addNewItemButton?.isEnabled = !AccountManager.shared.activeAccounts.isEmpty - } - func setFilterButtonToActive() { filterButton?.image = AppAssets.filterActiveImage filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Feeds", comment: "Selected - Filter Read Feeds") diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 87563f9f2..4cb77da86 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -111,13 +111,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner // MARK: Actions @IBAction func toggleFilter(_ sender: Any) { - if coordinator.isReadArticlesFiltered { - setFilterButtonToInactive() - coordinator.showAllArticles() - } else { - setFilterButtonToActive() - coordinator.hideReadArticles() - } + coordinator.toggleReadArticlesFilter() } @IBAction func markAllAsRead(_ sender: Any) { @@ -589,11 +583,13 @@ private extension MasterTimelineViewController { } if coordinator.isReadArticlesFiltered { - setFilterButtonToActive() + filterButton?.image = AppAssets.filterActiveImage + filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Articles", comment: "Selected - Filter Read Articles") } else { - setFilterButtonToInactive() + filterButton?.image = AppAssets.filterInactiveImage + filterButton?.accLabelText = NSLocalizedString("Filter Read Articles", comment: "Filter Read Articles") } - + tableView.selectRow(at: nil, animated: false, scrollPosition: .top) if resetScroll && dataSource.snapshot().itemIdentifiers(inSection: 0).count > 0 { tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false) @@ -603,16 +599,6 @@ private extension MasterTimelineViewController { } - func setFilterButtonToActive() { - filterButton?.image = AppAssets.filterActiveImage - filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Articles", comment: "Selected - Filter Read Articles") - } - - func setFilterButtonToInactive() { - filterButton?.image = AppAssets.filterInactiveImage - filterButton?.accLabelText = NSLocalizedString("Filter Read Articles", comment: "Filter Read Articles") - } - func updateToolbar() { markAllAsReadButton.isEnabled = coordinator.isTimelineUnreadAvailable firstUnreadButton.isEnabled = coordinator.isTimelineUnreadAvailable diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index 6f02ab425..df3805331 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -94,6 +94,14 @@ class RootSplitViewController: UISplitViewController { coordinator.cleanUp() } + @objc func toggleReadFeedsFilter(_ sender: Any?) { + coordinator.toggleReadFeedsFilter() + } + + @objc func toggleReadArticlesFilter(_ sender: Any?) { + coordinator.toggleReadArticlesFilter() + } + @objc func refresh(_ sender: Any?) { appDelegate.manualRefresh(errorHandler: ErrorHandler.present(self)) } diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 14fbb5e1d..3c5f552af 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -581,6 +581,30 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } } + func toggleReadFeedsFilter() { + if isReadFeedsFiltered { + treeControllerDelegate.isReadFiltered = false + } else { + treeControllerDelegate.isReadFiltered = true + } + rebuildBackingStores() + masterFeedViewController?.updateUI() + } + + func toggleReadArticlesFilter() { + guard let feedID = timelineFeed?.feedID else { + return + } + + if isReadArticlesFiltered { + readFilterEnabledTable[feedID] = false + } else { + readFilterEnabledTable[feedID] = true + } + + refreshTimeline(resetScroll: false) + } + func shadowNodesFor(section: Int) -> [Node] { return shadowTable[section] } @@ -617,30 +641,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } } - func showAllFeeds() { - treeControllerDelegate.isReadFiltered = false - rebuildBackingStores() - } - - func hideReadFeeds() { - treeControllerDelegate.isReadFiltered = true - rebuildBackingStores() - } - - func showAllArticles() { - if let feedID = timelineFeed?.feedID { - readFilterEnabledTable[feedID] = false - } - refreshTimeline(resetScroll: false) - } - - func hideReadArticles() { - if let feedID = timelineFeed?.feedID { - readFilterEnabledTable[feedID] = true - } - refreshTimeline(resetScroll: false) - } - func isExpanded(_ containerIdentifiable: ContainerIdentifiable) -> Bool { if let containerID = containerIdentifiable.containerID { return expandedTable.contains(containerID)