From cc6767e0f6b1a71bfbc588a1fcd4ff6bb6c6d2df Mon Sep 17 00:00:00 2001 From: Phil Viso Date: Fri, 13 Sep 2019 08:29:56 -0500 Subject: [PATCH] Removed duplicate sort parameter change handling functions --- .../Timeline/TimelineViewController.swift | 13 +++---------- iOS/SceneCoordinator.swift | 12 ++++-------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index bda2a0ba6..16a694d09 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -126,14 +126,14 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr private var sortDirection = AppDefaults.timelineSortDirection { didSet { if sortDirection != oldValue { - sortDirectionDidChange() + sortParametersDidChange() } } } private var groupByFeed = AppDefaults.timelineGroupByFeed { didSet { if groupByFeed != oldValue { - groupByFeedDidChange() + sortParametersDidChange() } } } @@ -884,20 +884,13 @@ private extension TimelineViewController { } } - func sortDirectionDidChange() { + func sortParametersDidChange() { performBlockAndRestoreSelection { let unsortedArticles = Set(articles) replaceArticles(with: unsortedArticles) } } - func groupByFeedDidChange() { - performBlockAndRestoreSelection { - let unsortedArticles = Set(articles) - replaceArticles(with: unsortedArticles) - } - } - func selectedArticleIDs() -> [String] { return selectedArticles.articleIDs() diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index f249a77d1..275a2d3ac 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -66,14 +66,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { private(set) var sortDirection = AppDefaults.timelineSortDirection { didSet { if sortDirection != oldValue { - sortDirectionDidChange() + sortParametersDidChange() } } } private(set) var groupByFeed = AppDefaults.timelineGroupByFeed { didSet { if groupByFeed != oldValue { - groupByFeedDidChange() + sortParametersDidChange() } } } @@ -1234,14 +1234,10 @@ private extension SceneCoordinator { } } - func sortDirectionDidChange() { + func sortParametersDidChange() { replaceArticles(with: Set(articles), animate: true) } - - func groupByFeedDidChange() { - replaceArticles(with: Set(articles), animate: true) - } - + func replaceArticles(with unsortedArticles: Set
, animate: Bool) { let sortedArticles = Array(unsortedArticles).sortedByDate(sortDirection, groupByFeed: groupByFeed)