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,9 +548,10 @@ 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() {
guard let node = coordinator.rootNode.descendantNodeRepresentingObject(webFeed as AnyObject) else {
completion?() completion?()
return return
} }
@ -571,13 +572,28 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
coordinator.expand(parent) coordinator.expand(parent)
reloadNode(parent) reloadNode(parent)
self.applyChanges(animated: true, adjustScroll: true) { [weak self] in applyChanges(animated: true, adjustScroll: true) { [weak self] in
if let indexPath = self?.dataSource.indexPath(for: node) { if let indexPath = self?.dataSource.indexPath(for: node) {
self?.coordinator.selectFeed(indexPath, animated: animated) { self?.coordinator.selectFeed(indexPath, animated: animated) {
completion?() 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()
}
} }