Removed duplicate sort parameter change handling functions

This commit is contained in:
Phil Viso 2019-09-13 08:29:56 -05:00
parent 8a6e3c9f37
commit cc6767e0f6
2 changed files with 7 additions and 18 deletions

View File

@ -126,14 +126,14 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
private var sortDirection = AppDefaults.timelineSortDirection { private var sortDirection = AppDefaults.timelineSortDirection {
didSet { didSet {
if sortDirection != oldValue { if sortDirection != oldValue {
sortDirectionDidChange() sortParametersDidChange()
} }
} }
} }
private var groupByFeed = AppDefaults.timelineGroupByFeed { private var groupByFeed = AppDefaults.timelineGroupByFeed {
didSet { didSet {
if groupByFeed != oldValue { if groupByFeed != oldValue {
groupByFeedDidChange() sortParametersDidChange()
} }
} }
} }
@ -884,20 +884,13 @@ private extension TimelineViewController {
} }
} }
func sortDirectionDidChange() { func sortParametersDidChange() {
performBlockAndRestoreSelection { performBlockAndRestoreSelection {
let unsortedArticles = Set(articles) let unsortedArticles = Set(articles)
replaceArticles(with: unsortedArticles) replaceArticles(with: unsortedArticles)
} }
} }
func groupByFeedDidChange() {
performBlockAndRestoreSelection {
let unsortedArticles = Set(articles)
replaceArticles(with: unsortedArticles)
}
}
func selectedArticleIDs() -> [String] { func selectedArticleIDs() -> [String] {
return selectedArticles.articleIDs() return selectedArticles.articleIDs()

View File

@ -66,14 +66,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
private(set) var sortDirection = AppDefaults.timelineSortDirection { private(set) var sortDirection = AppDefaults.timelineSortDirection {
didSet { didSet {
if sortDirection != oldValue { if sortDirection != oldValue {
sortDirectionDidChange() sortParametersDidChange()
} }
} }
} }
private(set) var groupByFeed = AppDefaults.timelineGroupByFeed { private(set) var groupByFeed = AppDefaults.timelineGroupByFeed {
didSet { didSet {
if groupByFeed != oldValue { if groupByFeed != oldValue {
groupByFeedDidChange() sortParametersDidChange()
} }
} }
} }
@ -1234,14 +1234,10 @@ private extension SceneCoordinator {
} }
} }
func sortDirectionDidChange() { func sortParametersDidChange() {
replaceArticles(with: Set(articles), animate: true) replaceArticles(with: Set(articles), animate: true)
} }
func groupByFeedDidChange() {
replaceArticles(with: Set(articles), animate: true)
}
func replaceArticles(with unsortedArticles: Set<Article>, animate: Bool) { func replaceArticles(with unsortedArticles: Set<Article>, animate: Bool) {
let sortedArticles = Array(unsortedArticles).sortedByDate(sortDirection, groupByFeed: groupByFeed) let sortedArticles = Array(unsortedArticles).sortedByDate(sortDirection, groupByFeed: groupByFeed)