Skip to content

Commit

Permalink
Merge branch 'master' of github.com:weiran/Hackers into ios15
Browse files Browse the repository at this point in the history
  • Loading branch information
weiran committed Dec 4, 2021
2 parents f1e68db + 96f24e2 commit 3cab336
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion App/Comments/CommentsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ class CommentsViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()
setupCollectionView()
load()
}

deinit {
tearDownHandoff()
}

private func load(showSpinner: Bool = true) {
@objc private func load(showSpinner: Bool = true) {
if showSpinner {
tableView.backgroundView = TableViewBackgroundView.loadingBackgroundView()
}
Expand All @@ -61,6 +62,7 @@ class CommentsViewController: UITableViewController {
Loaf("Error connecting to Hacker News", state: .error, sender: self).show()
}.finally {
self.tableView.backgroundView = nil
self.refreshControl?.endRefreshing()
}
}

Expand Down Expand Up @@ -492,6 +494,17 @@ extension CommentsViewController: CommentDelegate {

// MARK: - Handoff
extension CommentsViewController {

private func setupCollectionView() {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(
self,
action: #selector(load),
for: .valueChanged
)
self.refreshControl = refreshControl
}

private func setupHandoff(with post: Post?, activityType: ActivityType) {
guard let post = post else {
return
Expand Down

0 comments on commit 3cab336

Please sign in to comment.