Reset the timeline middle position anytime we replace the articles. Issue #1565

This commit is contained in:
Maurice Parker 2020-01-08 11:06:41 -07:00
parent 15569e62b2
commit 078c5dbb5c
1 changed files with 6 additions and 3 deletions

View File

@ -257,7 +257,12 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
var currentArticle: Article? var currentArticle: Article?
private(set) var articles = ArticleArray() private(set) var articles = ArticleArray() {
didSet {
timelineMiddleIndexPath = nil
}
}
private var currentArticleRow: Int? { private var currentArticleRow: Int? {
guard let article = currentArticle else { return nil } guard let article = currentArticle else { return nil }
return articles.firstIndex(of: article) return articles.firstIndex(of: article)
@ -1230,7 +1235,6 @@ private extension SceneCoordinator {
func setTimelineFeed(_ feed: Feed?, animated: Bool, completion: (() -> Void)? = nil) { func setTimelineFeed(_ feed: Feed?, animated: Bool, completion: (() -> Void)? = nil) {
timelineFeed = feed timelineFeed = feed
timelineMiddleIndexPath = nil
fetchAndReplaceArticlesAsync(animated: animated) { fetchAndReplaceArticlesAsync(animated: animated) {
self.masterTimelineViewController?.reinitializeArticles(resetScroll: true) self.masterTimelineViewController?.reinitializeArticles(resetScroll: true)
@ -1497,7 +1501,6 @@ private extension SceneCoordinator {
func emptyTheTimeline() { func emptyTheTimeline() {
if !articles.isEmpty { if !articles.isEmpty {
timelineMiddleIndexPath = nil
replaceArticles(with: Set<Article>(), animated: false) replaceArticles(with: Set<Article>(), animated: false)
} }
} }