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)
}
func discloseFeed(_ feed: Feed) {
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
masterNavigationController.popViewController(animated: true)
masterFeedViewController.discloseFeed(feed)
masterFeedViewController.discloseFeed(feed) {
completion?()
}
}
func showSettings() {
@ -1119,7 +1121,7 @@ private extension AppCoordinator {
let targetSplit = ensureDoubleSplit().children.first as! UISplitViewController
targetSplit.showDetailViewController(controller, sender: self)
} else if rootSplitViewController.isCollapsed {
rootSplitViewController.showDetailViewController(controller, sender: self)
masterNavigationController.pushViewController(controller, animated: true)
} else {
if let shimController = rootSplitViewController.viewControllers.last {
shimController.replaceChildAndPinView(controller)
@ -1295,16 +1297,18 @@ private extension AppCoordinator {
return
}
discloseFeed(feedNode.representedObject as! Feed)
discloseFeed(feedNode.representedObject as! Feed) {
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 {
selectArticle(IndexPath(row: index, section: 0))
self.selectArticle(IndexPath(row: index, section: 0))
break
}
}
}
}
func findAccountNode(for activity: NSUserActivity) -> Node? {

View File

@ -400,7 +400,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
reloadAllVisibleCells()
}
func discloseFeed(_ feed: Feed) {
func discloseFeed(_ feed: Feed, completion: (() -> Void)? = nil) {
guard let node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else {
return
@ -424,6 +424,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
if let indexPath = self?.coordinator.indexPathFor(node) {
self?.tableView.scrollToRow(at: indexPath, at: .middle, animated: true)
self?.coordinator.selectFeed(indexPath)
completion?()
}
}