mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Consider sort direction when sorting the Article array for the timeline.
This commit is contained in:
@@ -64,9 +64,16 @@ extension Array where Element == Article {
|
||||
return indexes
|
||||
}
|
||||
|
||||
func sortedByDate() -> ArticleArray {
|
||||
func sortedByDate(_ sortDirection: ComparisonResult) -> ArticleArray {
|
||||
|
||||
return sorted(by: articleComparator)
|
||||
let articles = sorted { (article1, article2) -> Bool in
|
||||
if sortDirection == .orderedDescending {
|
||||
return article1.logicalDatePublished > article2.logicalDatePublished
|
||||
}
|
||||
return article1.logicalDatePublished < article2.logicalDatePublished
|
||||
}
|
||||
|
||||
return articles
|
||||
}
|
||||
|
||||
func canMarkAllAsRead() -> Bool {
|
||||
@@ -95,12 +102,4 @@ private extension Array where Element == Article {
|
||||
|
||||
return rowForArticleID(article.articleID)
|
||||
}
|
||||
|
||||
// MARK: Sorting
|
||||
|
||||
func articleComparator(_ article1: Article, article2: Article) -> Bool {
|
||||
|
||||
return article1.logicalDatePublished > article2.logicalDatePublished
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user