From f2ac6ff1df2a28129c99ae04afcb48bfd11f35be Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 26 Jan 2020 21:18:43 -0700 Subject: [PATCH] Add functionality to clear the timeline and article views if their respective items get collapsed or filtered. Issue #1708 --- iOS/SceneCoordinator.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 5d737cbfd..f159b9fc8 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -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 {