Add pull to refresh to the timeline.

This commit is contained in:
Maurice Parker 2019-04-18 14:36:22 -05:00
parent 04dab356eb
commit c9cf35ed1f
2 changed files with 20 additions and 4 deletions

View File

@ -76,10 +76,6 @@ class MasterViewController: UITableViewController, UndoableCommandRunner {
// MARK: Notifications
@objc private func refreshAccounts(_ sender: Any) {
AccountManager.shared.refreshAll()
}
@objc dynamic func progressDidChange(_ notification: Notification) {
if AccountManager.shared.combinedRefreshProgress.isComplete {
refreshControl?.endRefreshing()
@ -537,6 +533,10 @@ extension MasterViewController: MasterTableViewCellDelegate {
private extension MasterViewController {
@objc private func refreshAccounts(_ sender: Any) {
AccountManager.shared.refreshAll()
}
func rebuildBackingStoresAndReloadDataIfNeeded() {
if !animatingChanges && !BatchUpdate.shared.isPerforming {
treeController.rebuild()

View File

@ -111,7 +111,11 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(accountDidDownloadArticles(_:)), name: .AccountDidDownloadArticles, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(progressDidChange(_:)), name: .AccountRefreshProgressDidChange, object: nil)
refreshControl = UIRefreshControl()
refreshControl!.addTarget(self, action: #selector(refreshAccounts(_:)), for: .valueChanged)
}
override func viewDidAppear(_ animated: Bool) {
@ -238,6 +242,14 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
// MARK: Notifications
@objc dynamic func progressDidChange(_ notification: Notification) {
if AccountManager.shared.combinedRefreshProgress.isComplete {
refreshControl?.endRefreshing()
} else {
refreshControl?.beginRefreshing()
}
}
@objc func statusesDidChange(_ note: Notification) {
guard let articles = note.userInfo?[Account.UserInfoKey.articles] as? Set<Article> else {
@ -399,6 +411,10 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
private extension MasterTimelineViewController {
@objc private func refreshAccounts(_ sender: Any) {
AccountManager.shared.refreshAll()
}
func configureTimelineCell(_ cell: MasterTimelineTableViewCell, article: Article) {
var avatar = avatarFor(article)