mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltStoreCore] Updates StoreApp to support Patreon-exclusive apps
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22222" systemVersion="22G91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22225" systemVersion="22G91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
|
||||
<entity name="Account" representedClassName="Account" syncable="YES">
|
||||
<attribute name="appleID" attributeType="String"/>
|
||||
<attribute name="firstName" attributeType="String"/>
|
||||
@@ -188,6 +188,7 @@
|
||||
<attribute name="identifier" attributeType="String"/>
|
||||
<attribute name="localizedDescription" optional="YES" attributeType="String"/>
|
||||
<attribute name="name" attributeType="String"/>
|
||||
<attribute name="patreonURL" optional="YES" attributeType="URI"/>
|
||||
<attribute name="sourceURL" attributeType="URI"/>
|
||||
<attribute name="subtitle" optional="YES" attributeType="String"/>
|
||||
<attribute name="tintColor" optional="YES" attributeType="Transformable" valueTransformerName="ALTSecureValueTransformer"/>
|
||||
@@ -207,8 +208,13 @@
|
||||
<attribute name="downloadURL" attributeType="URI"/>
|
||||
<attribute name="iconURL" attributeType="URI"/>
|
||||
<attribute name="isBeta" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="isHiddenWithoutPledge" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="isPledged" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="isPledgeRequired" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="localizedDescription" attributeType="String"/>
|
||||
<attribute name="name" attributeType="String"/>
|
||||
<attribute name="pledgeAmount" optional="YES" attributeType="Decimal"/>
|
||||
<attribute name="pledgeCurrency" optional="YES" attributeType="String"/>
|
||||
<attribute name="screenshotURLs" attributeType="Transformable" valueTransformerName="ALTSecureValueTransformer"/>
|
||||
<attribute name="size" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
<attribute name="sortIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
||||
|
||||
@@ -203,8 +203,9 @@ public class Source: NSManagedObject, Fetchable, Decodable
|
||||
|
||||
/* Source Detail */
|
||||
@NSManaged public var subtitle: String?
|
||||
@NSManaged public var websiteURL: URL?
|
||||
@NSManaged public var localizedDescription: String?
|
||||
@NSManaged public var websiteURL: URL?
|
||||
@NSManaged public var patreonURL: URL?
|
||||
|
||||
// Optional properties with fallbacks.
|
||||
// `private` to prevent accidentally using instead of `effective[PropertyName]`
|
||||
@@ -257,6 +258,7 @@ public class Source: NSManagedObject, Fetchable, Decodable
|
||||
case headerImageURL = "headerURL"
|
||||
case websiteURL = "website"
|
||||
case tintColor
|
||||
case patreonURL
|
||||
|
||||
case apps
|
||||
case news
|
||||
@@ -287,6 +289,7 @@ public class Source: NSManagedObject, Fetchable, Decodable
|
||||
self.localizedDescription = try container.decodeIfPresent(String.self, forKey: .localizedDescription)
|
||||
self.iconURL = try container.decodeIfPresent(URL.self, forKey: .iconURL)
|
||||
self.headerImageURL = try container.decodeIfPresent(URL.self, forKey: .headerImageURL)
|
||||
self.patreonURL = try container.decodeIfPresent(URL.self, forKey: .patreonURL)
|
||||
|
||||
if let tintColorHex = try container.decodeIfPresent(String.self, forKey: .tintColor)
|
||||
{
|
||||
|
||||
@@ -91,6 +91,18 @@ extension PlatformURL: Comparable {
|
||||
|
||||
public typealias PlatformURLs = [PlatformURL]
|
||||
|
||||
extension StoreApp
|
||||
{
|
||||
private struct PatreonParameters: Decodable
|
||||
{
|
||||
var pledge: Decimal?
|
||||
var currency: String?
|
||||
var tiers: Set<String>?
|
||||
var benefit: String?
|
||||
var hidden: Bool?
|
||||
}
|
||||
}
|
||||
|
||||
@objc(StoreApp)
|
||||
public class StoreApp: NSManagedObject, Decodable, Fetchable
|
||||
{
|
||||
@@ -112,6 +124,14 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
|
||||
@NSManaged public private(set) var tintColor: UIColor?
|
||||
@NSManaged public private(set) var isBeta: Bool
|
||||
|
||||
@NSManaged public var isPledged: Bool
|
||||
@NSManaged public private(set) var isPledgeRequired: Bool
|
||||
@NSManaged public private(set) var isHiddenWithoutPledge: Bool
|
||||
@NSManaged public private(set) var pledgeCurrency: String?
|
||||
|
||||
@nonobjc public var pledgeAmount: Decimal? { _pledgeAmount as? Decimal }
|
||||
@NSManaged @objc(pledgeAmount) private var _pledgeAmount: NSDecimalNumber?
|
||||
|
||||
@NSManaged public var sortIndex: Int32
|
||||
|
||||
@objc public internal(set) var sourceIdentifier: String? {
|
||||
@@ -232,6 +252,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
|
||||
case size
|
||||
case isBeta = "beta"
|
||||
case versions
|
||||
case patreon
|
||||
|
||||
// Legacy
|
||||
case version
|
||||
@@ -380,6 +401,33 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
|
||||
in: context)
|
||||
try self.setVersions([appVersion])
|
||||
}
|
||||
|
||||
// Must _explicitly_ set to false to ensure it updates cached database value.
|
||||
self.isPledged = false
|
||||
|
||||
if let patreon = try container.decodeIfPresent(PatreonParameters.self, forKey: .patreon)
|
||||
{
|
||||
self.isPledgeRequired = true
|
||||
self.isHiddenWithoutPledge = patreon.hidden ?? false // Default to showing Patreon apps
|
||||
|
||||
if let pledge = patreon.pledge
|
||||
{
|
||||
self._pledgeAmount = pledge as NSDecimalNumber
|
||||
self.pledgeCurrency = patreon.currency ?? "USD" // Only set pledge currency if explicitly given pledge.
|
||||
}
|
||||
else if patreon.pledge == nil && patreon.tiers == nil && patreon.benefit == nil
|
||||
{
|
||||
// No conditions, so default to pledgeAmount of 0 to simplify logic.
|
||||
self._pledgeAmount = 0 as NSDecimalNumber
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.isPledgeRequired = false
|
||||
self.isHiddenWithoutPledge = false
|
||||
self._pledgeAmount = nil
|
||||
self.pledgeCurrency = nil
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user