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() super.viewDidLoad()
self.navigationController?.navigationItem.largeTitleDisplayMode = .never self.navigationController?.navigationItem.largeTitleDisplayMode = .never
webView.navigationDelegate = self webView.navigationDelegate = self
markAsRead()
reloadUI() reloadUI()
reloadHTML() reloadHTML()
NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(statusesDidChange(_:)), name: .StatusesDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(articleSelectionChange(_:)), name: .ArticleSelectionChange, object: navState) 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() { func reloadUI() {
guard let article = navState?.currentArticle else { guard let article = navState?.currentArticle else {
@ -86,6 +93,7 @@ class DetailViewController: UIViewController {
} }
@objc func articleSelectionChange(_ note: Notification) { @objc func articleSelectionChange(_ note: Notification) {
markAsRead()
reloadUI() reloadUI()
reloadHTML() reloadHTML()
} }

View File

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