Refactor mark as read for articles to be in the SceneCoordinator instead of in the DetailViewController
This commit is contained in:
parent
858bdb7f21
commit
a5298f0381
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue