diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 585178f01..0515e7cac 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -141,7 +141,8 @@ class ArticleViewController: UIViewController { } override func viewSafeAreaInsetsDidChange() { - UIView.animate(withDuration: 1) { + // When the bars are hiding, the bar hiding duration is used. In all other cases, execute immediately. + UIView.animate(withDuration: 0.0) { self.view.layoutIfNeeded() } } diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 1c8145aa5..7ce7a0123 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -76,8 +76,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner resetUI() applyChanges(animated: false) - title = coordinator.timelineFeed?.nameForDisplay ?? "Timeline" - // Restore the scroll position if we have one stored if let restoreIndexPath = coordinator.timelineMiddleIndexPath { tableView.scrollToRow(at: restoreIndexPath, at: .middle, animated: false) @@ -509,6 +507,8 @@ private extension MasterTimelineViewController { func resetUI() { + title = coordinator.timelineFeed?.nameForDisplay ?? "Timeline" + if let titleView = navigationItem.titleView as? MasterTimelineTitleView { titleView.iconView.iconImage = coordinator.timelineIconImage titleView.label.text = coordinator.timelineFeed?.nameForDisplay diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 227da9855..9bfc22697 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -269,7 +269,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { super.init() - for section in treeController.rootNode.childNodes { + for _ in treeController.rootNode.childNodes { shadowTable.append([Node]()) } @@ -519,7 +519,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { return indexPathFor(node) } - func selectFeed(_ indexPath: IndexPath?, animated: Bool, completion: (() -> Void)? = nil) { + func selectFeed(_ indexPath: IndexPath?, animated: Bool, deselectArticle: Bool = true, completion: (() -> Void)? = nil) { guard indexPath != currentFeedIndexPath else { completion?() return @@ -529,7 +529,9 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { masterFeedViewController.updateFeedSelection(animated: animated) emptyTheTimeline() - selectArticle(nil) + if deselectArticle { + selectArticle(nil) + } if let ip = indexPath, let node = nodeFor(ip), let feed = node.representedObject as? Feed { @@ -718,9 +720,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { return } - selectNextUnreadFeedFetcher() - if selectNextUnreadArticleInTimeline() { - activityManager.selectingNextUnread() + selectNextUnreadFeed() { + if self.selectNextUnreadArticleInTimeline() { + self.activityManager.selectingNextUnread() + } } } @@ -1315,7 +1318,7 @@ private extension SceneCoordinator { } - func selectNextUnreadFeedFetcher() { + func selectNextUnreadFeed(completion: @escaping () -> Void) { let indexPath: IndexPath = { if currentFeedIndexPath == nil { @@ -1338,15 +1341,19 @@ private extension SceneCoordinator { } }() - if selectNextUnreadFeedFetcher(startingWith: nextIndexPath) { - return + selectNextUnreadFeed(startingWith: nextIndexPath) { found in + if !found { + self.selectNextUnreadFeed(startingWith: IndexPath(row: 0, section: 0)) { _ in + completion() + } + } else { + completion() + } } - selectNextUnreadFeedFetcher(startingWith: IndexPath(row: 0, section: 0)) } - @discardableResult - func selectNextUnreadFeedFetcher(startingWith indexPath: IndexPath) -> Bool { + func selectNextUnreadFeed(startingWith indexPath: IndexPath, completion: @escaping (Bool) -> Void) { for i in indexPath.section.. 0 { - selectFeed(nextIndexPath, animated: true) - return true + selectFeed(nextIndexPath, animated: false, deselectArticle: false) { + completion(true) + } + return } } } - return false + completion(false) }