mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Replaces PatreonAccount.isFriendZone with ManagedPatron
Rather than store both the current user’s Patreon account and all cached Friend Zone patrons in the same table, we now store Friend Zone patrons in the new ManagedPatron table. This avoids the need to distinguish between the two at runtime.
This commit is contained in:
@@ -87,7 +87,6 @@
|
||||
<entity name="PatreonAccount" representedClassName="PatreonAccount" syncable="YES">
|
||||
<attribute name="firstName" optional="YES" attributeType="String"/>
|
||||
<attribute name="identifier" attributeType="String"/>
|
||||
<attribute name="isFriendZonePatron" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||
<attribute name="isPatron" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
|
||||
<attribute name="name" attributeType="String"/>
|
||||
<uniquenessConstraints>
|
||||
@@ -178,7 +177,7 @@
|
||||
<element name="InstalledApp" positionX="-63" positionY="0" width="128" height="268"/>
|
||||
<element name="InstalledExtension" positionX="-45" positionY="135" width="128" height="163"/>
|
||||
<element name="NewsItem" positionX="-45" positionY="126" width="128" height="238"/>
|
||||
<element name="PatreonAccount" positionX="-45" positionY="117" width="128" height="104"/>
|
||||
<element name="PatreonAccount" positionX="-45" positionY="117" width="128" height="89"/>
|
||||
<element name="RefreshAttempt" positionX="-45" positionY="117" width="128" height="105"/>
|
||||
<element name="Source" positionX="-45" positionY="99" width="128" height="133"/>
|
||||
<element name="StoreApp" positionX="-63" positionY="-18" width="128" height="343"/>
|
||||
|
||||
@@ -38,7 +38,6 @@ public class PatreonAccount: NSManagedObject, Fetchable
|
||||
@NSManaged public var firstName: String?
|
||||
|
||||
@NSManaged public var isPatron: Bool
|
||||
@NSManaged public var isFriendZonePatron: NSNumber?
|
||||
|
||||
private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?)
|
||||
{
|
||||
@@ -63,16 +62,6 @@ public class PatreonAccount: NSManagedObject, Fetchable
|
||||
self.isPatron = false
|
||||
}
|
||||
}
|
||||
|
||||
public init(patron: Patron, context: NSManagedObjectContext)
|
||||
{
|
||||
super.init(entity: PatreonAccount.entity(), insertInto: context)
|
||||
|
||||
self.identifier = patron.identifier
|
||||
self.name = patron.name
|
||||
self.firstName = nil
|
||||
self.isPatron = (patron.status == .active)
|
||||
}
|
||||
}
|
||||
|
||||
public extension PatreonAccount
|
||||
|
||||
@@ -246,10 +246,8 @@ public extension PatreonAPI
|
||||
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
|
||||
do
|
||||
{
|
||||
if let account = DatabaseManager.shared.patreonAccount(in: context)
|
||||
{
|
||||
context.delete(account)
|
||||
}
|
||||
let accounts = PatreonAccount.all(in: context, requestProperties: [\.returnsObjectsAsFaults: true])
|
||||
accounts.forEach(context.delete(_:))
|
||||
|
||||
self.deactivateBetaApps(in: context)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user