From a9e8cec90e2e9b372ded29f9256ab7ef346ff2f8 Mon Sep 17 00:00:00 2001 From: Stuart Breckenridge Date: Thu, 14 May 2020 17:10:55 +0800 Subject: [PATCH] Key commands work with action sheets --- .../MasterTimelineViewController.swift | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 54f1f8bb9..be746ed92 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -117,12 +117,20 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner @IBAction func markAllAsRead(_ sender: Any) { let title = NSLocalizedString("Mark All as Read", comment: "Mark All as Read") - guard let barButtonItem = sender as? UIBarButtonItem else { - return + if let source = sender as? UIBarButtonItem { + MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: source) { [weak self] in + self?.coordinator.markAllAsReadInTimeline() + } } - MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: barButtonItem) { [weak self] in - self?.coordinator.markAllAsReadInTimeline() + if let _ = sender as? UIKeyCommand { + guard let indexPath = tableView.indexPathForSelectedRow, let contentView = tableView.cellForRow(at: indexPath)?.contentView else { + return + } + + MarkAsReadAlertController.confirm(self, coordinator: coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in + self?.coordinator.markAllAsReadInTimeline() + } } }