diff --git a/Classes/Issues/IssuesViewController.swift b/Classes/Issues/IssuesViewController.swift index 2a60c1c83..1119fbaa2 100644 --- a/Classes/Issues/IssuesViewController.swift +++ b/Classes/Issues/IssuesViewController.swift @@ -619,8 +619,8 @@ final class IssuesViewController: MessageViewController, // MARK: EmptyViewDelegate - func didTapRetry() { - self.feed.refreshHead() + func didTapRetry(view: EmptyView) { + feed.refreshHead() } // MARK: MessageTextViewListener diff --git a/Classes/PullRequestReviews/PullRequestReviewCommentsViewController.swift b/Classes/PullRequestReviews/PullRequestReviewCommentsViewController.swift index bf9543476..c73bd58ba 100644 --- a/Classes/PullRequestReviews/PullRequestReviewCommentsViewController.swift +++ b/Classes/PullRequestReviews/PullRequestReviewCommentsViewController.swift @@ -193,8 +193,8 @@ final class PullRequestReviewCommentsViewController: MessageViewController, // MARK: EmptyViewDelegate - func didTapRetry() { - self.feed.refreshHead() + func didTapRetry(view: EmptyView) { + feed.refreshHead() } // MARK: IssueTextActionsViewSendDelegate diff --git a/Classes/Repository/RepositoryCodeBlobViewController.swift b/Classes/Repository/RepositoryCodeBlobViewController.swift index 40f3ccfb5..f5399976f 100644 --- a/Classes/Repository/RepositoryCodeBlobViewController.swift +++ b/Classes/Repository/RepositoryCodeBlobViewController.swift @@ -169,8 +169,8 @@ final class RepositoryCodeBlobViewController: UIViewController, EmptyViewDelegat // MARK: EmptyViewDelegate - func didTapRetry() { - self.onRefresh() + func didTapRetry(view: EmptyView) { + onRefresh() } } diff --git a/Classes/Repository/RepositoryWebViewController.swift b/Classes/Repository/RepositoryWebViewController.swift index 3ec576d02..159c09aa4 100644 --- a/Classes/Repository/RepositoryWebViewController.swift +++ b/Classes/Repository/RepositoryWebViewController.swift @@ -133,8 +133,8 @@ extension RepositoryWebViewController: WKNavigationDelegate { extension RepositoryWebViewController: EmptyViewDelegate { - func didTapRetry() { - self.fetch() + func didTapRetry(view: EmptyView) { + fetch() } } diff --git a/Classes/Search/SearchViewController.swift b/Classes/Search/SearchViewController.swift index 1721324fe..e73c5df7d 100644 --- a/Classes/Search/SearchViewController.swift +++ b/Classes/Search/SearchViewController.swift @@ -235,7 +235,7 @@ class SearchViewController: UIViewController, // MARK: EmptyViewDelegate - func didTapRetry() { + func didTapRetry(view: EmptyView) { searchBar.resignFirstResponder() guard let term = searchTerm(for: searchBar.text) else { return } diff --git a/Classes/View Controllers/BaseListViewController.swift b/Classes/View Controllers/BaseListViewController.swift index 36b7a9cc2..a2a0c493f 100644 --- a/Classes/View Controllers/BaseListViewController.swift +++ b/Classes/View Controllers/BaseListViewController.swift @@ -78,7 +78,7 @@ LoadMoreSectionControllerDelegate { // MARK: Public API final func update(animated: Bool) { - self.feed.finishLoading(dismissRefresh: true, animated: animated) + feed.finishLoading(dismissRefresh: true, animated: animated) } final func update( @@ -88,9 +88,9 @@ LoadMoreSectionControllerDelegate { ) { assert(Thread.isMainThread) - self.hasError = false + hasError = false self.page = page - self.feed.finishLoading(dismissRefresh: true, animated: animated, completion: completion) + feed.finishLoading(dismissRefresh: true, animated: animated, completion: completion) } final func error( @@ -179,8 +179,11 @@ LoadMoreSectionControllerDelegate { // MARK: EmptyViewDelegate - func didTapRetry() { - self.feed.refreshHead() + func didTapRetry(view: EmptyView) { + // order is required to hide the error empty view while loading + feed.refreshHead() + hasError = false + feed.adapter.performUpdates(animated: false, completion: nil) } // MARK: LoadMoreSectionControllerDelegate diff --git a/Classes/View Controllers/BaseListViewController2.swift b/Classes/View Controllers/BaseListViewController2.swift index 949210316..1ca14c717 100644 --- a/Classes/View Controllers/BaseListViewController2.swift +++ b/Classes/View Controllers/BaseListViewController2.swift @@ -169,8 +169,11 @@ EmptyViewDelegate { // MARK: EmptyViewDelegate - func didTapRetry() { - self.feed.refreshHead() + func didTapRetry(view: EmptyView) { + // order is required to hide the error empty view while loading + feed.refreshHead() + hasError = false + feed.adapter.performUpdates(animated: false, completion: nil) } } diff --git a/Classes/Views/Constants.swift b/Classes/Views/Constants.swift index 85b863c56..966792c8d 100644 --- a/Classes/Views/Constants.swift +++ b/Classes/Views/Constants.swift @@ -56,7 +56,6 @@ enum Constants { static let assignees = NSLocalizedString("Assignees", comment: "") static let reviewers = NSLocalizedString("Reviewers", comment: "") static let reviewGitHubAccess = NSLocalizedString("Review GitHub Access", comment: "") - static let tryAgain = NSLocalizedString("Try Again", comment: "") static let clear = NSLocalizedString("Clear", comment: "") } } diff --git a/Classes/Views/EmptyView.swift b/Classes/Views/EmptyView.swift index 945f9c951..03418ed10 100644 --- a/Classes/Views/EmptyView.swift +++ b/Classes/Views/EmptyView.swift @@ -10,7 +10,7 @@ import UIKit import SnapKit protocol EmptyViewDelegate: class { - func didTapRetry() + func didTapRetry(view: EmptyView) } final class EmptyView: UIView { @@ -30,8 +30,8 @@ final class EmptyView: UIView { addSubview(label) button.isHidden = true - button.titleLabel?.font = Styles.Text.button.preferredFont - button.setTitle(Constants.Strings.tryAgain, for: .normal) + button.titleLabel?.font = Styles.Text.secondaryBold.preferredFont + button.setTitle(NSLocalizedString("Try Again", comment: ""), for: .normal) button.setTitleColor(Styles.Colors.Blue.medium.color, for: .normal) button.addTarget(self, action: #selector(tapRetry), for: .touchUpInside) addSubview(button) @@ -43,7 +43,7 @@ final class EmptyView: UIView { button.snp.makeConstraints { make in make.centerX.equalTo(self) - make.top.equalTo(label).offset(Styles.Sizes.gutter) + make.top.equalTo(label).offset(2*Styles.Sizes.gutter) } } @@ -52,6 +52,6 @@ final class EmptyView: UIView { } @objc private func tapRetry(sender: UIButton) { - delegate?.didTapRetry() + delegate?.didTapRetry(view: self) } }