diff --git a/iOS/Detail/DetailViewController.swift b/iOS/Detail/DetailViewController.swift index 8c3164bff..77475adfa 100644 --- a/iOS/Detail/DetailViewController.swift +++ b/iOS/Detail/DetailViewController.swift @@ -50,9 +50,7 @@ class DetailViewController: UIViewController { NSLayoutConstraint.activate(constraints) - markAsRead() - updateUI() - reloadHTML() + updateArticleSelection() NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil) @@ -65,12 +63,6 @@ class DetailViewController: UIViewController { updateProgressIndicatorIfNeeded() } - func markAsRead() { - if let article = coordinator.currentArticle { - markArticles(Set([article]), statusKey: .read, flag: true) - } - } - func updateUI() { guard let article = coordinator.currentArticle else { @@ -174,7 +166,6 @@ class DetailViewController: UIViewController { // MARK: API func updateArticleSelection() { - markAsRead() updateUI() reloadHTML() } diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 72c65d074..251fdae5a 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -120,7 +120,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { var timelineFetcher: ArticleFetcher? { didSet { - currentArticleIndexPath = nil + selectArticle(nil) if timelineFetcher is Feed { showFeedNames = false } else { @@ -186,14 +186,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { return nil } - private(set) var currentArticleIndexPath: IndexPath? { - didSet { - if currentArticleIndexPath != oldValue { - masterTimelineViewController?.updateArticleSelection(animate: true) - detailViewController?.updateArticleSelection() - } - } - } + private(set) var currentArticleIndexPath: IndexPath? private(set) var articles = ArticleArray() { didSet { @@ -506,6 +499,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { currentArticleIndexPath = indexPath activityManager.reading(currentArticle) + if let article = currentArticle { + markArticles(Set([article]), statusKey: .read, flag: true) + } + if indexPath == nil { if !rootSplitViewController.isCollapsed { let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self) @@ -527,6 +524,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } rootSplitViewController.preferredDisplayMode = .automatic } + + masterTimelineViewController?.updateArticleSelection(animate: true) + detailViewController?.updateArticleSelection() + } func searchArticles(_ searchString: String, _ searchScope: SearchScope) {