mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-25 09:41:00 +00:00
Only refresh or alert if visible
This commit is contained in:
parent
94d0b2338f
commit
11f5a3a914
2 changed files with 12 additions and 2 deletions
|
@ -5,6 +5,8 @@ import UIKit
|
|||
import ViewModels
|
||||
|
||||
extension UIViewController {
|
||||
var isVisible: Bool { isViewLoaded && view.window != nil && presentedViewController == nil }
|
||||
|
||||
func present(alertItem: AlertItem) {
|
||||
let alertController = UIAlertController(
|
||||
title: nil,
|
||||
|
|
|
@ -422,7 +422,11 @@ private extension TableViewController {
|
|||
|
||||
viewModel.alertItems
|
||||
.compactMap { $0 }
|
||||
.sink { [weak self] in self?.present(alertItem: $0) }
|
||||
.sink { [weak self] in
|
||||
guard let self = self, self.isVisible else { return }
|
||||
|
||||
self.present(alertItem: $0)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
tableView.publisher(for: \.contentOffset)
|
||||
|
@ -444,7 +448,11 @@ private extension TableViewController {
|
|||
|
||||
NotificationCenter.default.publisher(for: UIScene.willEnterForegroundNotification)
|
||||
.merge(with: NotificationCenter.default.publisher(for: NewStatusViewController.newStatusPostedNotification))
|
||||
.sink { [weak self] _ in self?.refreshIfAble() }
|
||||
.sink { [weak self] _ in
|
||||
guard let self = self, self.isVisible else { return }
|
||||
|
||||
self.refreshIfAble()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
NotificationCenter.default.publisher(for: LoadMoreView.accessibilityCustomAction)
|
||||
|
|
Loading…
Reference in a new issue