Animate navigation for First Unread. Issue #1071

This commit is contained in:
Maurice Parker 2019-09-30 12:36:25 -05:00
parent d59b5016de
commit a7bee3a6d5
1 changed files with 21 additions and 16 deletions

View File

@ -556,11 +556,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
func selectArticle(_ article: Article?, automated: Bool = true) { func selectArticle(_ article: Article?, automated: Bool = true) {
guard article != currentArticle else { return } guard article != currentArticle else { return }
articleExtractor?.cancel() stopArticleExtractor()
articleExtractor = nil
isShowingExtractedArticle = false
articleViewController?.articleExtractorButtonState = .off
currentArticle = article currentArticle = article
activityManager.reading(currentArticle) activityManager.reading(currentArticle)
@ -576,10 +572,13 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
return return
} }
let currentArticleViewController: ArticleViewController
if articleViewController == nil { if articleViewController == nil {
let articleViewController = UIStoryboard.main.instantiateController(ofType: ArticleViewController.self) currentArticleViewController = UIStoryboard.main.instantiateController(ofType: ArticleViewController.self)
articleViewController.coordinator = self currentArticleViewController.coordinator = self
installArticleController(articleViewController, automated: automated) installArticleController(currentArticleViewController, automated: automated)
} else {
currentArticleViewController = articleViewController!
} }
if automated { if automated {
@ -588,9 +587,9 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
if article!.feed?.isArticleExtractorAlwaysOn ?? false { if article!.feed?.isArticleExtractorAlwaysOn ?? false {
startArticleExtractorForCurrentLink() startArticleExtractorForCurrentLink()
articleViewController?.state = .loading currentArticleViewController.state = .loading
} else { } else {
articleViewController?.state = .article(article!) currentArticleViewController.state = .article(article!)
} }
markArticles(Set([article!]), statusKey: .read, flag: true) markArticles(Set([article!]), statusKey: .read, flag: true)
@ -828,10 +827,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
} }
guard articleExtractor?.state != .processing else { guard articleExtractor?.state != .processing else {
articleExtractor?.cancel() stopArticleExtractor()
articleExtractor = nil
isShowingExtractedArticle = false
articleViewController?.articleExtractorButtonState = .off
articleViewController?.state = .article(article) articleViewController?.state = .article(article)
return return
} }
@ -933,7 +929,9 @@ extension SceneCoordinator: UINavigationControllerDelegate {
// If we are using a phone and navigate away from the detail, clear up the article resources (including activity) // If we are using a phone and navigate away from the detail, clear up the article resources (including activity)
if viewController === masterTimelineViewController && !isThreePanelMode && rootSplitViewController.isCollapsed { if viewController === masterTimelineViewController && !isThreePanelMode && rootSplitViewController.isCollapsed {
selectArticle(nil) stopArticleExtractor()
currentArticle = nil
activityManager.invalidateReading()
} }
} }
@ -1180,7 +1178,7 @@ private extension SceneCoordinator {
for i in startingRow..<articles.count { for i in startingRow..<articles.count {
let article = articles[i] let article = articles[i]
if !article.status.read { if !article.status.read {
selectArticle(article) selectArticle(article, automated: false)
return true return true
} }
} }
@ -1268,6 +1266,13 @@ private extension SceneCoordinator {
} }
} }
func stopArticleExtractor() {
articleExtractor?.cancel()
articleExtractor = nil
isShowingExtractedArticle = false
articleViewController?.articleExtractorButtonState = .off
}
func emptyTheTimeline() { func emptyTheTimeline() {
if !articles.isEmpty { if !articles.isEmpty {
replaceArticles(with: Set<Article>(), animate: true) replaceArticles(with: Set<Article>(), animate: true)