Move mark as read functionality to the detail view.

This commit is contained in:
Maurice Parker 2019-04-22 07:08:54 -05:00
parent 05f8dc38c4
commit 5b75add585
2 changed files with 9 additions and 4 deletions

View File

@ -29,12 +29,19 @@ class DetailViewController: UIViewController {
super.viewDidLoad()
self.navigationController?.navigationItem.largeTitleDisplayMode = .never
webView.navigationDelegate = self
markAsRead()
reloadUI()
reloadHTML()
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(articleSelectionChange(_:)), name: .ArticleSelectionChange, object: navState)
}
func markAsRead() {
if let article = navState?.currentArticle {
markArticles(Set([article]), statusKey: .read, flag: true)
}
}
func reloadUI() {
guard let article = navState?.currentArticle else {
@ -86,6 +93,7 @@ class DetailViewController: UIViewController {
}
@objc func articleSelectionChange(_ note: Notification) {
markAsRead()
reloadUI()
reloadHTML()
}

View File

@ -270,10 +270,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
@objc func articleSelectionChange(_ note: Notification) {
if let indexPath = navState?.currentArticleIndexPath, let article = navState?.articles[indexPath.row] {
if !article.status.read {
markArticles(Set([article]), statusKey: .read, flag: true)
}
if let indexPath = navState?.currentArticleIndexPath {
// TODO: make this scroll like the desktop version
if tableView.indexPathForSelectedRow != indexPath {
tableView.selectRow(at: indexPath, animated: true, scrollPosition: .middle)