Move mark as read functionality to the detail view.
This commit is contained in:
parent
05f8dc38c4
commit
5b75add585
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue