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() {
// This should never happen, but I don't want to risk throwing us
@ -718,9 +722,13 @@ private extension AppCoordinator {
// MARK: Select Next Unread
@discardableResult
func selectFirstUnreadArticleInTimeline() -> Bool {
return selectArticleInTimeline(startingRow: 0)
}
@discardableResult
func selectNextUnreadArticleInTimeline() -> Bool {
let startingRow: Int = {
if let indexPath = currentArticleIndexPath {
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 {
let article = articles[i]
if !article.status.read {
currentArticleIndexPath = IndexPath(row: i, section: 0)
selectArticle(IndexPath(row: i, section: 0))
return true
}
}

View File

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