diff --git a/iOS/AppDefaults.swift b/iOS/AppDefaults.swift index f29b7d191..ddf3789c5 100644 --- a/iOS/AppDefaults.swift +++ b/iOS/AppDefaults.swift @@ -20,6 +20,7 @@ struct AppDefaults { static let lastImageCacheFlushDate = "lastImageCacheFlushDate" static let firstRunDate = "firstRunDate" static let timelineGroupByFeed = "timelineGroupByFeed" + static let refreshClearsReadArticles = "refreshClearsReadArticles" static let timelineNumberOfLines = "timelineNumberOfLines" static let timelineIconSize = "timelineIconSize" static let timelineSortDirection = "timelineSortDirection" @@ -84,6 +85,15 @@ struct AppDefaults { } } + static var refreshClearsReadArticles: Bool { + get { + return bool(for: Key.refreshClearsReadArticles) + } + set { + setBool(for: Key.refreshClearsReadArticles, newValue) + } + } + static var timelineSortDirection: ComparisonResult { get { return sortDirection(for: Key.timelineSortDirection) @@ -142,6 +152,7 @@ struct AppDefaults { static func registerDefaults() { let defaults: [String : Any] = [Key.lastImageCacheFlushDate: Date(), Key.timelineGroupByFeed: false, + Key.refreshClearsReadArticles: false, Key.timelineNumberOfLines: 2, Key.timelineIconSize: IconSize.medium.rawValue, Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 771c31382..ce32cb10a 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -437,10 +437,15 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner { @objc func refreshAccounts(_ sender: Any) { refreshControl?.endRefreshing() + // This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl. // If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears. DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) + AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) { + if AppDefaults.refreshClearsReadArticles { + self.coordinator.refreshTimeline(resetScroll: false) + } + } } } diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index fde3fd9b1..7d4dca9c5 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -139,10 +139,15 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner @objc func refreshAccounts(_ sender: Any) { refreshControl?.endRefreshing() + // This is a hack to make sure that an error dialog doesn't interfere with dismissing the refreshControl. // If the error dialog appears too closely to the call to endRefreshing, then the refreshControl never disappears. DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) + AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) { + if AppDefaults.refreshClearsReadArticles { + self.coordinator.refreshTimeline(resetScroll: false) + } + } } } diff --git a/iOS/Settings/Settings.storyboard b/iOS/Settings/Settings.storyboard index 9c1d18cbc..6555971dc 100644 --- a/iOS/Settings/Settings.storyboard +++ b/iOS/Settings/Settings.storyboard @@ -177,14 +177,44 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + @@ -202,13 +232,13 @@ - + -