Stop skipping the Today feed when finding next unread and looping around

This commit is contained in:
Maurice Parker 2020-07-27 21:21:11 -05:00
parent ecefe59a5e
commit ff829c0e59
1 changed files with 4 additions and 8 deletions

View File

@ -271,23 +271,19 @@ private extension SidebarModel {
if let feedID = nextUnread(sidebarItems: sidebarItems, startingAt: startFeed) { if let feedID = nextUnread(sidebarItems: sidebarItems, startingAt: startFeed) {
return feedID return feedID
} else { } else {
if let firstFeed = sidebarItems.first?.children.first?.feed { return nextUnread(sidebarItems: sidebarItems, startingAt: nil)
return nextUnread(sidebarItems: sidebarItems, startingAt: firstFeed)
} }
} }
return nil
}
@discardableResult @discardableResult
func nextUnread(sidebarItems: [SidebarItem], startingAt: Feed) -> FeedIdentifier? { func nextUnread(sidebarItems: [SidebarItem], startingAt: Feed?) -> FeedIdentifier? {
var foundStartFeed = false var foundStartFeed = startingAt == nil ? true : false
var nextSidebarItem: SidebarItem? = nil var nextSidebarItem: SidebarItem? = nil
for section in sidebarItems { for section in sidebarItems {
if nextSidebarItem == nil { if nextSidebarItem == nil {
section.visit { sidebarItem in section.visit { sidebarItem in
if !foundStartFeed && sidebarItem.feed?.feedID == startingAt.feedID { if !foundStartFeed && sidebarItem.feed?.feedID == startingAt?.feedID {
foundStartFeed = true foundStartFeed = true
return false return false
} }