mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
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:
parent
0269683b16
commit
e39972bd64
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user