Fix bug that prevented reading article user activities from being restored

This commit is contained in:
Maurice Parker 2019-08-31 20:23:14 -05:00
parent 87030a5921
commit 27883632d0
2 changed files with 15 additions and 10 deletions

View File

@ -663,9 +663,11 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
runCommand(markReadCommand) runCommand(markReadCommand)
} }
func discloseFeed(_ feed: Feed) { func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
masterNavigationController.popViewController(animated: true) masterNavigationController.popViewController(animated: true)
masterFeedViewController.discloseFeed(feed) masterFeedViewController.discloseFeed(feed) {
completion?()
}
} }
func showSettings() { func showSettings() {
@ -1119,7 +1121,7 @@ private extension AppCoordinator {
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 {
rootSplitViewController.showDetailViewController(controller, sender: self) masterNavigationController.pushViewController(controller, animated: true)
} else { } else {
if let shimController = rootSplitViewController.viewControllers.last { if let shimController = rootSplitViewController.viewControllers.last {
shimController.replaceChildAndPinView(controller) shimController.replaceChildAndPinView(controller)
@ -1295,15 +1297,17 @@ private extension AppCoordinator {
return return
} }
discloseFeed(feedNode.representedObject as! Feed) discloseFeed(feedNode.representedObject as! Feed) {
guard let articleID = activity.userInfo?[ActivityID.articleID.rawValue] as? String else { return } guard let articleID = activity.userInfo?[ActivityID.articleID.rawValue] as? String else { return }
for (index, article) in articles.enumerated() { for (index, article) in self.articles.enumerated() {
if article.articleID == articleID { if article.articleID == articleID {
selectArticle(IndexPath(row: index, section: 0)) self.selectArticle(IndexPath(row: index, section: 0))
break break
}
} }
} }
} }

View File

@ -400,7 +400,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
reloadAllVisibleCells() reloadAllVisibleCells()
} }
func discloseFeed(_ feed: Feed) { 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 return
@ -424,6 +424,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
if let indexPath = self?.coordinator.indexPathFor(node) { if let indexPath = self?.coordinator.indexPathFor(node) {
self?.tableView.scrollToRow(at: indexPath, at: .middle, animated: true) self?.tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
self?.coordinator.selectFeed(indexPath) self?.coordinator.selectFeed(indexPath)
completion?()
} }
} }