Add functionality to clear the timeline and article views if their respective items get collapsed or filtered. Issue #1708

This commit is contained in:
Maurice Parker 2020-01-26 21:18:43 -07:00
parent 81e71051ef
commit f2ac6ff1df
1 changed files with 12 additions and 0 deletions

View File

@ -594,6 +594,9 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
func refreshTimeline(resetScroll: Bool) {
fetchAndReplaceArticlesAsync(animated: true) {
self.masterTimelineViewController?.reinitializeArticles(resetScroll: resetScroll)
if let article = self.currentArticle, self.articles.firstIndex(of: article) == nil {
self.selectArticle(nil)
}
}
}
@ -654,6 +657,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
animatingChanges = true
rebuildShadowTable()
animatingChanges = false
clearTimelineIfNoLongerAvailable()
}
func collapseAllFolders() {
@ -668,6 +672,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
animatingChanges = true
rebuildShadowTable()
animatingChanges = false
clearTimelineIfNoLongerAvailable()
}
func masterFeedIndexPathForCurrentTimeline() -> IndexPath? {
@ -1224,6 +1229,7 @@ private extension SceneCoordinator {
updateExpandedNodes?()
rebuildShadowTable()
masterFeedViewController.reloadFeeds(initialLoad: initialLoad)
clearTimelineIfNoLongerAvailable()
}
}
@ -1261,6 +1267,12 @@ private extension SceneCoordinator {
}
return false
}
func clearTimelineIfNoLongerAvailable() {
if let feed = timelineFeed, !shadowTableContains(feed) {
selectFeed(nil, animated: false, deselectArticle: true)
}
}
func nodeFor(_ indexPath: IndexPath) -> Node? {
guard indexPath.section < shadowTable.count && indexPath.row < shadowTable[indexPath.section].count else {