Auto expand accounts that may have been suspended as collapsed when disclosing a feed. Issue #1440

This commit is contained in:
Maurice Parker 2019-12-19 09:38:53 -07:00
parent 3a33c38d5c
commit 8fb92e119a
1 changed files with 40 additions and 24 deletions

View File

@ -548,35 +548,51 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
} }
} }
func discloseFeed(_ feed: WebFeed, animated: Bool, completion: (() -> Void)? = nil) { func discloseFeed(_ webFeed: WebFeed, animated: Bool, completion: (() -> Void)? = nil) {
guard let node = coordinator.rootNode.descendantNodeRepresentingObject(feed as AnyObject) else { func discloseFeedInAccount() {
completion?() guard let node = coordinator.rootNode.descendantNodeRepresentingObject(webFeed as AnyObject) else {
return
}
if let indexPath = dataSource.indexPath(for: node) {
coordinator.selectFeed(indexPath, animated: animated) {
completion?() completion?()
return
} }
return
}
// It wasn't already visable, so expand its folder and try again if let indexPath = dataSource.indexPath(for: node) {
guard let parent = node.parent else { coordinator.selectFeed(indexPath, animated: animated) {
completion?()
return
}
coordinator.expand(parent)
reloadNode(parent)
self.applyChanges(animated: true, adjustScroll: true) { [weak self] in
if let indexPath = self?.dataSource.indexPath(for: node) {
self?.coordinator.selectFeed(indexPath, animated: animated) {
completion?() completion?()
} }
return
} }
// It wasn't already visable, so expand its folder and try again
guard let parent = node.parent else {
completion?()
return
}
coordinator.expand(parent)
reloadNode(parent)
applyChanges(animated: true, adjustScroll: true) { [weak self] in
if let indexPath = self?.dataSource.indexPath(for: node) {
self?.coordinator.selectFeed(indexPath, animated: animated) {
completion?()
}
}
}
}
// If the account for the feed is collapsed, expand it
if let account = webFeed.account,
let accountNode = coordinator.rootNode.childNodeRepresentingObject(account as AnyObject),
!coordinator.isExpanded(accountNode) {
coordinator.expand(accountNode)
applyChanges(animated: false) {
discloseFeedInAccount()
}
} else {
discloseFeedInAccount()
} }
} }