From df3c78b1c67c79b1a3217e7dda87aafbee7e751b Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 30 Jan 2020 18:37:22 -0700 Subject: [PATCH] Change next/prev feed searches so that they skip collapsed sections. Issue#1755 --- iOS/SceneCoordinator.swift | 45 ++++++++++++++------------------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 4daa24072..b09d74094 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -161,37 +161,19 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { private(set) var showFeedNames = false private(set) var showIcons = false - var isPrevFeedAvailable: Bool { - guard let indexPath = currentFeedIndexPath else { - return false - } - return indexPath.section > 0 || indexPath.row > 0 - } - - var isNextFeedAvailable: Bool { - guard let indexPath = currentFeedIndexPath else { - return false - } - - let nextIndexPath: IndexPath = { - if indexPath.row + 1 >= shadowTable[indexPath.section].count { - return IndexPath(row: 0, section: indexPath.section + 1) - } else { - return IndexPath(row: indexPath.row + 1, section: indexPath.section) - } - }() - - return nextIndexPath.section < shadowTable.count && nextIndexPath.row < shadowTable[nextIndexPath.section].count - } - var prevFeedIndexPath: IndexPath? { - guard isPrevFeedAvailable, let indexPath = currentFeedIndexPath else { + guard let indexPath = currentFeedIndexPath else { return nil } - let prevIndexPath: IndexPath = { + let prevIndexPath: IndexPath? = { if indexPath.row - 1 < 0 { - return IndexPath(row: shadowTable[indexPath.section - 1].count - 1, section: indexPath.section - 1) + for i in (0.. 0 { + return IndexPath(row: shadowTable[i].count - 1, section: i) + } + } + return nil } else { return IndexPath(row: indexPath.row - 1, section: indexPath.section) } @@ -201,13 +183,18 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } var nextFeedIndexPath: IndexPath? { - guard isNextFeedAvailable, let indexPath = currentFeedIndexPath else { + guard let indexPath = currentFeedIndexPath else { return nil } - let nextIndexPath: IndexPath = { + let nextIndexPath: IndexPath? = { if indexPath.row + 1 >= shadowTable[indexPath.section].count { - return IndexPath(row: 0, section: indexPath.section + 1) + for i in indexPath.section + 1.. 0 { + return IndexPath(row: 0, section: i) + } + } + return nil } else { return IndexPath(row: indexPath.row + 1, section: indexPath.section) }