Switches from StoreApp.isBeta to isPledged to determine whether app is visible

If StoreApp.isHiddenWithoutPledge == false (default), we’ll still show the app.
This commit is contained in:
Riley Testut
2023-11-29 18:08:42 -06:00
committed by Magesh K
parent aa9fda7a97
commit 389af4d5e6
6 changed files with 25 additions and 16 deletions

View File

@@ -93,7 +93,6 @@ class BrowseViewController: UICollectionViewController, PeekPopPreviewing
super.viewWillAppear(animated) super.viewWillAppear(animated)
self.fetchSource() self.fetchSource()
self.updateDataSource()
self.update() self.update()
} }
@@ -110,7 +109,8 @@ private extension BrowseViewController
NSSortDescriptor(keyPath: \StoreApp.bundleIdentifier, ascending: true)] NSSortDescriptor(keyPath: \StoreApp.bundleIdentifier, ascending: true)]
fetchRequest.returnsObjectsAsFaults = false fetchRequest.returnsObjectsAsFaults = false
let predicate = NSPredicate(format: "%K != %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID) let predicate = StoreApp.visibleAppsPredicate
if let source = self.source if let source = self.source
{ {
let filterPredicate = NSPredicate(format: "%K == %@", #keyPath(StoreApp._source), source) let filterPredicate = NSPredicate(format: "%K == %@", #keyPath(StoreApp._source), source)

View File

@@ -113,11 +113,10 @@ class MyAppsViewController: UICollectionViewController, PeekPopPreviewing
(self as PeekPopPreviewing).registerForPreviewing(with: self, sourceView: self.collectionView) (self as PeekPopPreviewing).registerForPreviewing(with: self, sourceView: self.collectionView)
} }
override func viewWillAppear(_ animated: Bool) override func viewIsAppearing(_ animated: Bool)
{ {
super.viewWillAppear(animated) super.viewIsAppearing(animated)
self.updateDataSource()
self.update() self.update()
self.fetchAppIDs() self.fetchAppIDs()

View File

@@ -215,7 +215,7 @@ private extension SourceDetailContentViewController
let dataSource = RSTArrayCollectionViewPrefetchingDataSource<StoreApp, UIImage>(items: limitedFeaturedApps) let dataSource = RSTArrayCollectionViewPrefetchingDataSource<StoreApp, UIImage>(items: limitedFeaturedApps)
dataSource.cellIdentifierHandler = { _ in "AppCell" } dataSource.cellIdentifierHandler = { _ in "AppCell" }
dataSource.predicate = NSPredicate(format: "%K == NO", #keyPath(StoreApp.isBeta)) // Never show beta apps (at least until we support betas for other sources). dataSource.predicate = StoreApp.visibleAppsPredicate
dataSource.cellConfigurationHandler = { [weak self] (cell, storeApp, indexPath) in dataSource.cellConfigurationHandler = { [weak self] (cell, storeApp, indexPath) in
let cell = cell as! AppBannerCollectionViewCell let cell = cell as! AppBannerCollectionViewCell
cell.tintColor = storeApp.tintColor cell.tintColor = storeApp.tintColor

View File

@@ -231,15 +231,7 @@ private extension SourcesViewController
cell.bannerView.iconImageView.image = nil cell.bannerView.iconImageView.image = nil
cell.bannerView.iconImageView.isIndicatingActivity = true cell.bannerView.iconImageView.isIndicatingActivity = true
let numberOfApps: Int let numberOfApps = source.apps.filter { StoreApp.visibleAppsPredicate.evaluate(with: $0) }.count
if let patreonAccount = DatabaseManager.shared.patreonAccount(), patreonAccount.isPatron, PatreonAPI.shared.isAuthenticated
{
numberOfApps = source.apps.count
}
else
{
numberOfApps = source.apps.filter { !$0.isBeta }.count
}
if let error = source.error if let error = source.error
{ {

View File

@@ -212,13 +212,19 @@ public extension InstalledApp
// We have to also check !(latestSupportedVersion.buildVersion == '' && installedApp.storeBuildVersion == nil) // We have to also check !(latestSupportedVersion.buildVersion == '' && installedApp.storeBuildVersion == nil)
// because latestSupportedVersion.buildVersion stores an empty string for nil, while installedApp.storeBuildVersion uses NULL. // because latestSupportedVersion.buildVersion stores an empty string for nil, while installedApp.storeBuildVersion uses NULL.
"(%K != %K OR (%K != %K AND NOT (%K == '' AND %K == nil)))", "(%K != %K OR (%K != %K AND NOT (%K == '' AND %K == nil)))",
"AND",
// !isPledgeRequired || isPledged
"(%K == NO OR %K == YES)"
].joined(separator: " ") ].joined(separator: " ")
fetchRequest.predicate = NSPredicate(format: predicateFormat, fetchRequest.predicate = NSPredicate(format: predicateFormat,
#keyPath(InstalledApp.isActive), #keyPath(InstalledApp.storeApp), #keyPath(InstalledApp.storeApp.latestSupportedVersion), #keyPath(InstalledApp.isActive), #keyPath(InstalledApp.storeApp), #keyPath(InstalledApp.storeApp.latestSupportedVersion),
#keyPath(InstalledApp.storeApp.latestSupportedVersion.version), #keyPath(InstalledApp.version), #keyPath(InstalledApp.storeApp.latestSupportedVersion.version), #keyPath(InstalledApp.version),
#keyPath(InstalledApp.storeApp.latestSupportedVersion._buildVersion), #keyPath(InstalledApp.storeBuildVersion), #keyPath(InstalledApp.storeApp.latestSupportedVersion._buildVersion), #keyPath(InstalledApp.storeBuildVersion),
#keyPath(InstalledApp.storeApp.latestSupportedVersion._buildVersion), #keyPath(InstalledApp.storeBuildVersion)) #keyPath(InstalledApp.storeApp.latestSupportedVersion._buildVersion), #keyPath(InstalledApp.storeBuildVersion),
#keyPath(InstalledApp.storeApp.isPledgeRequired), #keyPath(InstalledApp.storeApp.isPledged))
return fetchRequest return fetchRequest
} }

View File

@@ -569,6 +569,18 @@ public extension StoreApp
let globallyUniqueID = self.bundleIdentifier + "|" + sourceIdentifier let globallyUniqueID = self.bundleIdentifier + "|" + sourceIdentifier
return globallyUniqueID return globallyUniqueID
} }
}
public extension StoreApp
{
class var visibleAppsPredicate: NSPredicate {
let predicate = NSPredicate(format: "(%K != %@) AND ((%K == NO) OR (%K == NO) OR (%K == YES))",
#keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID,
#keyPath(StoreApp.isPledgeRequired),
#keyPath(StoreApp.isHiddenWithoutPledge),
#keyPath(StoreApp.isPledged))
return predicate
}
@nonobjc class func fetchRequest() -> NSFetchRequest<StoreApp> @nonobjc class func fetchRequest() -> NSFetchRequest<StoreApp>
{ {