mirror of
https://github.com/metabolist/metatext.git
synced 2024-05-19 16:58:06 +00:00
Refresh modifications
This commit is contained in:
parent
08d4e43ddb
commit
6800055ced
|
@ -96,6 +96,10 @@ final class NewStatusViewController: UIViewController {
|
|||
}
|
||||
}
|
||||
|
||||
extension NewStatusViewController {
|
||||
static let newStatusPostedNotification = Notification.Name("com.metabolist.metatext.new-status-posted-notification")
|
||||
}
|
||||
|
||||
extension NewStatusViewController: PHPickerViewControllerDelegate {
|
||||
func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
|
||||
mediaSelections.send(results)
|
||||
|
@ -169,6 +173,7 @@ private extension NewStatusViewController {
|
|||
stackView.isUserInteractionEnabled = false
|
||||
stackView.alpha = 0.5
|
||||
case .done:
|
||||
NotificationCenter.default.post(.init(name: Self.newStatusPostedNotification))
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class TableViewController: UITableViewController {
|
|||
refreshControl = UIRefreshControl()
|
||||
refreshControl?.addAction(
|
||||
UIAction { [weak self] _ in
|
||||
self?.viewModel.request(maxId: nil, minId: nil, search: nil) },
|
||||
self?.refreshIfAble() },
|
||||
for: .valueChanged)
|
||||
}
|
||||
|
||||
|
@ -69,12 +69,14 @@ class TableViewController: UITableViewController {
|
|||
])
|
||||
|
||||
setupViewModelBindings()
|
||||
|
||||
viewModel.request(maxId: nil, minId: nil, search: nil)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
viewModel.request(maxId: nil, minId: nil, search: nil)
|
||||
refreshIfAble()
|
||||
}
|
||||
|
||||
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
|
@ -289,7 +291,8 @@ private extension TableViewController {
|
|||
.store(in: &cancellables)
|
||||
|
||||
NotificationCenter.default.publisher(for: UIScene.willEnterForegroundNotification)
|
||||
.sink { [weak self] _ in self?.viewModel.request(maxId: nil, minId: nil, search: nil) }
|
||||
.merge(with: NotificationCenter.default.publisher(for: NewStatusViewController.newStatusPostedNotification))
|
||||
.sink { [weak self] _ in self?.refreshIfAble() }
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
|
@ -492,5 +495,11 @@ private extension TableViewController {
|
|||
|
||||
present(activityViewController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func refreshIfAble() {
|
||||
if viewModel.canRefresh {
|
||||
viewModel.request(maxId: nil, minId: nil, search: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
// swiftlint:enable file_length
|
||||
|
|
Loading…
Reference in a new issue