From 6844762dfc0c2eafad41004e74f00ecb92e512b6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 29 Aug 2019 15:02:45 -0500 Subject: [PATCH] Refresh smart feeds when they are selected and articles are downloaded --- iOS/AppCoordinator.swift | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/iOS/AppCoordinator.swift b/iOS/AppCoordinator.swift index 4a7d629cb..cbc36870d 100644 --- a/iOS/AppCoordinator.swift +++ b/iOS/AppCoordinator.swift @@ -273,7 +273,11 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } @objc func containerChildrenDidChange(_ note: Notification) { - rebuildBackingStores() + if timelineFetcherContainsAnyPseudoFeed() || timelineFetcherContainsAnyFolder() { + fetchAndReplaceArticlesAsync() { [weak self] in + self?.rebuildBackingStores() + } + } } @objc func batchUpdateDidPerform(_ notification: Notification) { @@ -951,7 +955,7 @@ private extension AppCoordinator { replaceArticles(with: fetchedArticles) } - func fetchAndReplaceArticlesAsync() { + func fetchAndReplaceArticlesAsync(completion: @escaping () -> Void) { // To be called when we need to do an entire fetch, but an async delay is okay. // Example: we have the Today feed selected, and the calendar day just changed. cancelPendingAsyncFetches() @@ -961,6 +965,7 @@ private extension AppCoordinator { } fetchUnsortedArticlesAsync(for: [timelineFetcher]) { [weak self] (articles) in self?.replaceArticles(with: articles) + completion() } } @@ -1000,6 +1005,13 @@ private extension AppCoordinator { return false } + func timelineFetcherContainsAnyFolder() -> Bool { + if timelineFetcher is Folder { + return true + } + return false + } + func timelineFetcherContainsAnyFeed(_ feeds: Set) -> Bool { // Return true if there’s a match or if a folder contains (recursively) one of feeds