Fix infinite loop that could happen on going to next unread. Fix #269.

This commit is contained in:
Brent Simmons 2017-12-23 22:18:42 -08:00
parent 97f306b556
commit 24fb1f0356
2 changed files with 23 additions and 9 deletions

View File

@ -166,23 +166,39 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
openArticleInBrowser(sender)
}
func makeTimelineViewFirstResponder() {
guard let window = window, let timelineViewController = timelineViewController else {
return
}
window.makeFirstResponderUnlessDescendantIsFirstResponder(timelineViewController.tableView)
}
@IBAction func nextUnread(_ sender: Any?) {
guard let timelineViewController = timelineViewController, let sidebarViewController = sidebarViewController else {
return
}
func makeTimelineViewFirstResponder() {
window!.makeFirstResponderUnlessDescendantIsFirstResponder(timelineViewController.tableView)
}
if timelineViewController.canGoToNextUnread() {
timelineViewController.goToNextUnread()
makeTimelineViewFirstResponder()
goToNextUnreadInTimeline()
}
else if sidebarViewController.canGoToNextUnread() {
sidebarViewController.goToNextUnread()
if timelineViewController.canGoToNextUnread() {
goToNextUnreadInTimeline()
}
}
}
func goToNextUnreadInTimeline() {
guard let timelineViewController = timelineViewController else {
return
}
if timelineViewController.canGoToNextUnread() {
timelineViewController.goToNextUnread()
makeTimelineViewFirstResponder()
}
}

View File

@ -151,8 +151,6 @@ import RSCore
}
outlineView.selectRowIndexes(IndexSet([row]), byExtendingSelection: false)
NSApplication.shared.sendAction(NSSelectorFromString("nextUnread:"), to: nil, from: self)
}
func focus() {