From b25e789aef323c686066a7a4a5c32df4a41eaaaa Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 18 Jul 2019 15:16:54 -0500 Subject: [PATCH] Prevent refresh errors from keeping the refreshControl visible when error dialogs are displayed. --- iOS/MasterFeed/MasterFeedViewController.swift | 8 ++++++-- iOS/MasterTimeline/MasterTimelineViewController.swift | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/iOS/MasterFeed/MasterFeedViewController.swift b/iOS/MasterFeed/MasterFeedViewController.swift index 9fdfc1a12..987163f9f 100644 --- a/iOS/MasterFeed/MasterFeedViewController.swift +++ b/iOS/MasterFeed/MasterFeedViewController.swift @@ -596,10 +596,14 @@ extension MasterFeedViewController: MasterFeedTableViewCellDelegate { private extension MasterFeedViewController { @objc private func refreshAccounts(_ sender: Any) { - AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) 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)) + } } - + func updateUI() { markAllAsReadButton.isEnabled = coordinator.isAnyUnreadAvailable addNewItemButton.isEnabled = !AccountManager.shared.activeAccounts.isEmpty diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 57935590d..2965d4e02 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -339,8 +339,12 @@ class MasterTimelineViewController: ProgressTableViewController, UndoableCommand private extension MasterTimelineViewController { @objc private func refreshAccounts(_ sender: Any) { - AccountManager.shared.refreshAll(errorHandler: ErrorHandler.present(self)) 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)) + } } func resetUI() {