Reload affected tables on reload receipt

This commit is contained in:
Davide De Rosa 2019-11-02 11:28:35 +01:00
parent ebbcaa674b
commit f9093715a8
3 changed files with 18 additions and 1 deletions

View File

@ -33,6 +33,8 @@ import PassepartoutCore
private let log = SwiftyBeaver.self
class ProductManager: NSObject {
static let didReloadReceipt = Notification.Name("ProductManagerDidReloadReceipt")
private static let lastFullVersionBuild = 2016 // 1.8.1
static let shared = ProductManager()
@ -133,6 +135,8 @@ class ProductManager: NSObject {
}
}
log.info("Purchased features: \(purchasedFeatures)")
NotificationCenter.default.post(name: ProductManager.didReloadReceipt, object: nil)
}
func isFullVersion() -> Bool {

View File

@ -125,7 +125,9 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
// see UISplitViewControllerDelegate in AppDelegate (collapse is now commented out)
service.delegate = self
NotificationCenter.default.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidChangeStatus, object: nil)
let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidChangeStatus, object: nil)
nc.addObserver(self, selector: #selector(productManagerDidReloadReceipt), name: ProductManager.didReloadReceipt, object: nil)
}
override func viewDidAppear(_ animated: Bool) {
@ -362,6 +364,11 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
@objc private func vpnDidUpdate() {
tableView.reloadData()
}
@objc private func productManagerDidReloadReceipt() {
reloadModel()
tableView.reloadData()
}
}
// MARK: -

View File

@ -117,6 +117,7 @@ class ServiceViewController: UIViewController, StrongTableHost {
nc.addObserver(self, selector: #selector(vpnDidUpdate), name: .VPNDidReinstall, object: nil)
nc.addObserver(self, selector: #selector(intentDidUpdateService), name: .IntentDidUpdateService, object: nil)
nc.addObserver(self, selector: #selector(serviceDidUpdateDataCount(_:)), name: .ConnectionServiceDidUpdateDataCount, object: nil)
nc.addObserver(self, selector: #selector(productManagerDidReloadReceipt), name: ProductManager.didReloadReceipt, object: nil)
// run this no matter what
// XXX: convenient here vs AppDelegate for updating table
@ -666,6 +667,11 @@ class ServiceViewController: UIViewController, StrongTableHost {
}
refreshDataCount(dataCount)
}
@objc private func productManagerDidReloadReceipt() {
reloadModel()
tableView.reloadData()
}
}
// MARK: -