Fix bugs in automated routing on application launch
This commit is contained in:
parent
1e7ed5bf35
commit
9b17293f4e
@ -259,7 +259,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
|
|
||||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
becomeFirstResponder()
|
becomeFirstResponder()
|
||||||
coordinator.selectFeed(indexPath)
|
coordinator.selectFeed(indexPath, automated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath {
|
override func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath {
|
||||||
@ -469,17 +469,20 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
|||||||
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
|
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
|
||||||
|
|
||||||
guard let node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else {
|
guard let node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else {
|
||||||
return
|
completion?()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if let indexPath = coordinator.indexPathFor(node) {
|
if let indexPath = coordinator.indexPathFor(node) {
|
||||||
tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
|
tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
|
||||||
coordinator.selectFeed(indexPath)
|
coordinator.selectFeed(indexPath)
|
||||||
|
completion?()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// It wasn't already visable, so expand its folder and try again
|
// It wasn't already visable, so expand its folder and try again
|
||||||
guard let parent = node.parent, let indexPath = coordinator.indexPathFor(parent) else {
|
guard let parent = node.parent, let indexPath = coordinator.indexPathFor(parent) else {
|
||||||
|
completion?()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
var timelineFetcher: ArticleFetcher? {
|
var timelineFetcher: ArticleFetcher? {
|
||||||
didSet {
|
didSet {
|
||||||
|
|
||||||
selectArticle(nil)
|
|
||||||
if timelineFetcher is Feed {
|
if timelineFetcher is Feed {
|
||||||
showFeedNames = false
|
showFeedNames = false
|
||||||
} else {
|
} else {
|
||||||
@ -300,6 +299,8 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handle(_ activity: NSUserActivity) {
|
func handle(_ activity: NSUserActivity) {
|
||||||
|
selectFeed(nil)
|
||||||
|
|
||||||
guard let activityType = ActivityType(rawValue: activity.activityType) else { return }
|
guard let activityType = ActivityType(rawValue: activity.activityType) else { return }
|
||||||
switch activityType {
|
switch activityType {
|
||||||
case .selectToday:
|
case .selectToday:
|
||||||
@ -567,24 +568,28 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
return indexes
|
return indexes
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectFeed(_ indexPath: IndexPath?) {
|
func selectFeed(_ indexPath: IndexPath?, automated: Bool = true) {
|
||||||
if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 {
|
selectArticle(nil)
|
||||||
masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self)
|
|
||||||
masterTimelineViewController!.coordinator = self
|
|
||||||
navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
currentFeedIndexPath = indexPath
|
currentFeedIndexPath = indexPath
|
||||||
|
|
||||||
if let ip = indexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher {
|
if let ip = indexPath, let node = nodeFor(ip), let fetcher = node.representedObject as? ArticleFetcher {
|
||||||
timelineFetcher = fetcher
|
timelineFetcher = fetcher
|
||||||
updateSelectingActivity(with: node)
|
updateSelectingActivity(with: node)
|
||||||
|
|
||||||
|
if navControllerForTimeline().viewControllers.filter({ $0 is MasterTimelineViewController }).count < 1 {
|
||||||
|
masterTimelineViewController = UIStoryboard.main.instantiateController(ofType: MasterTimelineViewController.self)
|
||||||
|
masterTimelineViewController!.coordinator = self
|
||||||
|
navControllerForTimeline().pushViewController(masterTimelineViewController!, animated: !automated)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
timelineFetcher = nil
|
timelineFetcher = nil
|
||||||
|
|
||||||
|
if rootSplitViewController.isCollapsed && navControllerForTimeline().viewControllers.last is MasterTimelineViewController {
|
||||||
|
navControllerForTimeline().popViewController(animated: !automated)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
masterFeedViewController.updateFeedSelection()
|
masterFeedViewController.updateFeedSelection()
|
||||||
selectArticle(nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectPrevFeed() {
|
func selectPrevFeed() {
|
||||||
@ -626,9 +631,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if indexPath == nil {
|
if indexPath == nil {
|
||||||
if !rootSplitViewController.isCollapsed {
|
if rootSplitViewController.isCollapsed {
|
||||||
|
if masterNavigationController.children.last is DetailViewController {
|
||||||
|
masterNavigationController.popViewController(animated: false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self)
|
let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self)
|
||||||
installDetailController(systemMessageViewController)
|
installDetailController(systemMessageViewController, automated: automated)
|
||||||
}
|
}
|
||||||
masterTimelineViewController?.updateArticleSelection(animate: true)
|
masterTimelineViewController?.updateArticleSelection(animate: true)
|
||||||
return
|
return
|
||||||
@ -637,7 +646,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
if detailViewController == nil {
|
if detailViewController == nil {
|
||||||
let detailViewController = UIStoryboard.main.instantiateController(ofType: DetailViewController.self)
|
let detailViewController = UIStoryboard.main.instantiateController(ofType: DetailViewController.self)
|
||||||
detailViewController.coordinator = self
|
detailViewController.coordinator = self
|
||||||
installDetailController(detailViewController)
|
installDetailController(detailViewController, automated: automated)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically hide the overlay
|
// Automatically hide the overlay
|
||||||
@ -649,7 +658,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if automated {
|
if automated {
|
||||||
masterTimelineViewController?.updateArticleSelection(animate: true)
|
masterTimelineViewController?.updateArticleSelection(animate: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
detailViewController?.updateArticleSelection()
|
detailViewController?.updateArticleSelection()
|
||||||
@ -839,7 +848,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
|
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
|
||||||
masterNavigationController.popViewController(animated: true)
|
|
||||||
masterFeedViewController.discloseFeed(feed) {
|
masterFeedViewController.discloseFeed(feed) {
|
||||||
completion?()
|
completion?()
|
||||||
}
|
}
|
||||||
@ -1463,7 +1471,7 @@ private extension SceneCoordinator {
|
|||||||
// during the display mode change callback (in the split view controller delegate). To fool the
|
// during the display mode change callback (in the split view controller delegate). To fool the
|
||||||
// system, we leave the same controller, the shim, in place and change its child controllers instead.
|
// system, we leave the same controller, the shim, in place and change its child controllers instead.
|
||||||
|
|
||||||
func installDetailController(_ detailController: UIViewController) {
|
func installDetailController(_ detailController: UIViewController, automated: Bool) {
|
||||||
let showButton = rootSplitViewController.displayMode != .allVisible
|
let showButton = rootSplitViewController.displayMode != .allVisible
|
||||||
let controller = addNavControllerIfNecessary(detailController, showButton: showButton)
|
let controller = addNavControllerIfNecessary(detailController, showButton: showButton)
|
||||||
|
|
||||||
@ -1471,7 +1479,7 @@ private extension SceneCoordinator {
|
|||||||
let targetSplit = ensureDoubleSplit().children.first as! UISplitViewController
|
let targetSplit = ensureDoubleSplit().children.first as! UISplitViewController
|
||||||
targetSplit.showDetailViewController(controller, sender: self)
|
targetSplit.showDetailViewController(controller, sender: self)
|
||||||
} else if rootSplitViewController.isCollapsed {
|
} else if rootSplitViewController.isCollapsed {
|
||||||
masterNavigationController.pushViewController(controller, animated: true)
|
masterNavigationController.pushViewController(controller, animated: !automated)
|
||||||
} else {
|
} else {
|
||||||
if let shimController = rootSplitViewController.viewControllers.last {
|
if let shimController = rootSplitViewController.viewControllers.last {
|
||||||
shimController.replaceChildAndPinView(controller)
|
shimController.replaceChildAndPinView(controller)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user