mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-23 08:09:41 +01:00
Simplify the article replacement logic
This commit is contained in:
parent
5cb099aee6
commit
640faaa114
@ -132,10 +132,6 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
|||||||
resetUI()
|
resetUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateArticles() {
|
|
||||||
reloadAllVisibleCells()
|
|
||||||
}
|
|
||||||
|
|
||||||
func reloadArticles(animate: Bool) {
|
func reloadArticles(animate: Bool) {
|
||||||
applyChanges(animate: animate) { [weak self] in
|
applyChanges(animate: animate) { [weak self] in
|
||||||
self?.updateArticleSelection(animate: animate)
|
self?.updateArticleSelection(animate: animate)
|
||||||
|
@ -176,22 +176,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
|
|
||||||
private(set) var currentArticleIndexPath: IndexPath?
|
private(set) var currentArticleIndexPath: IndexPath?
|
||||||
|
|
||||||
private(set) var articles = ArticleArray() {
|
private(set) var articles = ArticleArray()
|
||||||
didSet {
|
|
||||||
if articles == oldValue {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if articles.representSameArticlesInSameOrder(as: oldValue) {
|
|
||||||
articleRowMap = [String: Int]()
|
|
||||||
masterTimelineViewController?.updateArticles()
|
|
||||||
updateUnreadCount()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
updateShowAvatars()
|
|
||||||
articleRowMap = [String: Int]()
|
|
||||||
updateUnreadCount()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var isTimelineUnreadAvailable: Bool {
|
var isTimelineUnreadAvailable: Bool {
|
||||||
if let unreadProvider = timelineFetcher as? UnreadCountProvider {
|
if let unreadProvider = timelineFetcher as? UnreadCountProvider {
|
||||||
@ -1000,13 +985,21 @@ private extension SceneCoordinator {
|
|||||||
|
|
||||||
func replaceArticles(with unsortedArticles: Set<Article>, animate: Bool) {
|
func replaceArticles(with unsortedArticles: Set<Article>, animate: Bool) {
|
||||||
let sortedArticles = Array(unsortedArticles).sortedByDate(sortDirection)
|
let sortedArticles = Array(unsortedArticles).sortedByDate(sortDirection)
|
||||||
|
|
||||||
if articles != sortedArticles {
|
if articles != sortedArticles {
|
||||||
|
|
||||||
let article = currentArticle
|
let article = currentArticle
|
||||||
articles = sortedArticles
|
articles = sortedArticles
|
||||||
|
|
||||||
|
updateShowAvatars()
|
||||||
|
articleRowMap = [String: Int]()
|
||||||
|
updateUnreadCount()
|
||||||
|
|
||||||
masterTimelineViewController?.reloadArticles(animate: animate)
|
masterTimelineViewController?.reloadArticles(animate: animate)
|
||||||
if let articleID = article?.articleID, let index = indexForArticleID(articleID) {
|
if let articleID = article?.articleID, let index = indexForArticleID(articleID) {
|
||||||
currentArticleIndexPath = IndexPath(row: index, section: 0)
|
currentArticleIndexPath = IndexPath(row: index, section: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user