Merge branch 'restrict-feedback'
This commit is contained in:
commit
244337fbbe
|
@ -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()
|
||||
|
@ -41,7 +43,7 @@ class ProductManager: NSObject {
|
|||
|
||||
private var purchasedAppBuild: Int?
|
||||
|
||||
private(set) var purchasedFeatures: Set<Product>
|
||||
private var purchasedFeatures: Set<Product>
|
||||
|
||||
private var refreshRequest: SKReceiptRefreshRequest?
|
||||
|
||||
|
@ -133,6 +135,8 @@ class ProductManager: NSObject {
|
|||
}
|
||||
}
|
||||
log.info("Purchased features: \(purchasedFeatures)")
|
||||
|
||||
NotificationCenter.default.post(name: ProductManager.didReloadReceipt, object: nil)
|
||||
}
|
||||
|
||||
func isFullVersion() -> Bool {
|
||||
|
@ -157,6 +161,10 @@ class ProductManager: NSObject {
|
|||
return $0.rawValue.hasSuffix("providers.\(name.rawValue)")
|
||||
}
|
||||
}
|
||||
|
||||
func isEligibleForFeedback() -> Bool {
|
||||
return AppConstants.Flags.isBeta || !purchasedFeatures.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
extension ConnectionService {
|
||||
|
|
|
@ -44,8 +44,10 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
|
|||
|
||||
// MARK: StrongTableHost
|
||||
|
||||
let model: StrongTableModel<SectionType, RowType> = {
|
||||
let model: StrongTableModel<SectionType, RowType> = StrongTableModel()
|
||||
let model: StrongTableModel<SectionType, RowType> = StrongTableModel()
|
||||
|
||||
func reloadModel() {
|
||||
model.clear()
|
||||
model.add(.vpn)
|
||||
model.add(.providers)
|
||||
model.add(.hosts)
|
||||
|
@ -53,7 +55,9 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
|
|||
model.add(.siri)
|
||||
}
|
||||
model.add(.support)
|
||||
model.add(.feedback)
|
||||
if ProductManager.shared.isEligibleForFeedback() {
|
||||
model.add(.feedback)
|
||||
}
|
||||
model.add(.about)
|
||||
model.add(.destruction)
|
||||
model.setHeader(L10n.App.Service.Sections.Vpn.header, forSection: .vpn)
|
||||
|
@ -78,10 +82,9 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
|
|||
model.setHeader("Beta", forSection: .test)
|
||||
model.set([.testDisplayLog, .testTermination], forSection: .test)
|
||||
}
|
||||
return model
|
||||
}()
|
||||
|
||||
func reloadModel() {
|
||||
//
|
||||
|
||||
providers = service.ids(forContext: .provider).sorted()
|
||||
hosts = service.ids(forContext: .host).sortedCaseInsensitive()
|
||||
|
||||
|
@ -122,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) {
|
||||
|
@ -359,6 +364,11 @@ class OrganizerViewController: UITableViewController, StrongTableHost {
|
|||
@objc private func vpnDidUpdate() {
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
@objc private func productManagerDidReloadReceipt() {
|
||||
reloadModel()
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
|
|
|
@ -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: -
|
||||
|
@ -1158,7 +1164,9 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
|||
model.add(.trusted)
|
||||
model.add(.trustedPolicy)
|
||||
model.add(.diagnostics)
|
||||
model.add(.feedback)
|
||||
if ProductManager.shared.isEligibleForFeedback() {
|
||||
model.add(.feedback)
|
||||
}
|
||||
}
|
||||
|
||||
// headers
|
||||
|
|
Loading…
Reference in New Issue