From 8b6e2fa5178ef9ca8cc83b4dcb2510a048d27459 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 6 Jul 2019 12:31:07 -0500 Subject: [PATCH] Move more logic out of MasterTimelineViewController and into AppCoordinator --- iOS/AppCoordinator.swift | 9 +++++++++ iOS/MasterTimeline/MasterTimelineViewController.swift | 11 +---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/iOS/AppCoordinator.swift b/iOS/AppCoordinator.swift index ffe1e5a01..e89923bea 100644 --- a/iOS/AppCoordinator.swift +++ b/iOS/AppCoordinator.swift @@ -505,6 +505,15 @@ class AppCoordinator: UndoableCommandRunner { runCommand(markReadCommand) } + func markAllAsReadInTimeline() { + guard let undoManager = undoManager, + let markReadCommand = MarkStatusCommand(initialArticles: articles, markingRead: true, undoManager: undoManager) else { + return + } + runCommand(markReadCommand) + masterNavigationController.popViewController(animated: true) + } + func toggleReadForCurrentArticle() { if let article = currentArticle { markArticles(Set([article]), statusKey: .read, flag: !article.status.read) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 1bdd67d59..57935590d 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -90,16 +90,7 @@ class MasterTimelineViewController: ProgressTableViewController, UndoableCommand let markTitle = NSLocalizedString("Mark All Read", comment: "Mark All Read") let markAction = UIAlertAction(title: markTitle, style: .default) { [weak self] (action) in - - guard let articles = self?.coordinator.articles, - let undoManager = self?.undoManager, - let markReadCommand = MarkStatusCommand(initialArticles: articles, markingRead: true, undoManager: undoManager) else { - return - } - self?.runCommand(markReadCommand) - - self?.navigationController?.popViewController(animated: true) - + self?.coordinator.markAllAsReadInTimeline() } alertController.addAction(markAction)