Reinstant hide deleted profile after review

Also, viewWillAppear() is too early. If profile deletion happens
on launch, ServiceVC will not be aware of the change until
viewDidAppear().
This commit is contained in:
Davide De Rosa 2019-11-09 13:06:13 +01:00
parent 495e714737
commit e704c7fe6c
2 changed files with 9 additions and 1 deletions

View File

@ -35,6 +35,8 @@ private let log = SwiftyBeaver.self
class ProductManager: NSObject {
static let didReloadReceipt = Notification.Name("ProductManagerDidReloadReceipt")
static let didReviewPurchases = Notification.Name("ProductManagerDidReviewPurchases")
private static let lastFullVersionBuild = 2016 // 1.8.1
static let shared = ProductManager()
@ -223,7 +225,7 @@ class ProductManager: NSObject {
TransientStore.shared.serialize(withProfiles: true)
VPN.shared.uninstall(completionHandler: nil)
NotificationCenter.default.post(name: ProductManager.didReloadReceipt, object: nil)
NotificationCenter.default.post(name: ProductManager.didReviewPurchases, object: nil)
}
}

View File

@ -120,6 +120,7 @@ class ServiceViewController: UIViewController, StrongTableHost {
}
nc.addObserver(self, selector: #selector(serviceDidUpdateDataCount(_:)), name: ConnectionService.didUpdateDataCount, object: nil)
nc.addObserver(self, selector: #selector(productManagerDidReloadReceipt), name: ProductManager.didReloadReceipt, object: nil)
nc.addObserver(self, selector: #selector(productManagerDidReviewPurchases), name: ProductManager.didReviewPurchases, object: nil)
// run this no matter what
// XXX: convenient here vs AppDelegate for updating table
@ -141,6 +142,7 @@ class ServiceViewController: UIViewController, StrongTableHost {
super.viewDidAppear(animated)
clearSelection()
hideProfileIfDeleted()
}
override func didReceiveMemoryWarning() {
@ -674,6 +676,10 @@ class ServiceViewController: UIViewController, StrongTableHost {
reloadModel()
tableView.reloadData()
}
@objc private func productManagerDidReviewPurchases() {
hideProfileIfDeleted()
}
}
// MARK: -