Correct First Unread button to select the first unread in the timeline and show article in detail view. Issue #695

This commit is contained in:
Maurice Parker 2019-08-03 17:07:43 -05:00
parent 0269683b16
commit e39972bd64
2 changed files with 16 additions and 5 deletions

View File

@ -510,6 +510,10 @@ class AppCoordinator: NSObject, UndoableCommandRunner {
} }
} }
func selectFirstUnread() {
selectFirstUnreadArticleInTimeline()
}
func selectNextUnread() { func selectNextUnread() {
// This should never happen, but I don't want to risk throwing us // This should never happen, but I don't want to risk throwing us
@ -719,8 +723,12 @@ private extension AppCoordinator {
// MARK: Select Next Unread // MARK: Select Next Unread
@discardableResult @discardableResult
func selectNextUnreadArticleInTimeline() -> Bool { func selectFirstUnreadArticleInTimeline() -> Bool {
return selectArticleInTimeline(startingRow: 0)
}
@discardableResult
func selectNextUnreadArticleInTimeline() -> Bool {
let startingRow: Int = { let startingRow: Int = {
if let indexPath = currentArticleIndexPath { if let indexPath = currentArticleIndexPath {
return indexPath.row return indexPath.row
@ -729,10 +737,15 @@ private extension AppCoordinator {
} }
}() }()
return selectArticleInTimeline(startingRow: startingRow)
}
func selectArticleInTimeline(startingRow: Int) -> Bool {
for i in startingRow..<articles.count { for i in startingRow..<articles.count {
let article = articles[i] let article = articles[i]
if !article.status.read { if !article.status.read {
currentArticleIndexPath = IndexPath(row: i, section: 0) selectArticle(IndexPath(row: i, section: 0))
return true return true
} }
} }

View File

@ -107,9 +107,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
} }
@IBAction func firstUnread(_ sender: Any) { @IBAction func firstUnread(_ sender: Any) {
if let indexPath = coordinator.firstUnreadArticleIndexPath { coordinator.selectNextUnread()
tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
}
} }
// MARK: - Table view // MARK: - Table view