mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
- Minor fixes and cleanup
This commit is contained in:
@@ -222,7 +222,7 @@ extension MergePolicy{
|
||||
|
||||
// When conflict.databaseObject is available, it means this is replace (delete + insert) or update
|
||||
private func resolveWhenDatabaseObjectAvailable(_ conflicts: [NSConstraintConflict]) throws {
|
||||
|
||||
|
||||
for conflict in conflicts
|
||||
{
|
||||
switch conflict.databaseObject
|
||||
@@ -354,7 +354,7 @@ extension MergePolicy{
|
||||
do
|
||||
{
|
||||
var appVersions = databaseObject.versions
|
||||
|
||||
|
||||
if let globallyUniqueID = databaseObject.globallyUniqueID
|
||||
{
|
||||
// Permissions
|
||||
@@ -365,16 +365,16 @@ extension MergePolicy{
|
||||
// Sorting order doesn't matter, but elements themselves don't match so throw error.
|
||||
throw MergeError.incorrectPermissions(for: databaseObject)
|
||||
}
|
||||
|
||||
|
||||
// App versions
|
||||
if let sortedAppVersionIDs = sortedVersionIDsByGlobalAppID[globallyUniqueID],
|
||||
let sortedAppVersionsIDsArray = sortedAppVersionIDs.array as? [String],
|
||||
case let databaseVersionIDs = databaseObject.versions.map({ $0.versionID }),
|
||||
case let databaseVersionIDs = databaseObject.versions.map({ $0.versionID }),
|
||||
databaseVersionIDs != sortedAppVersionsIDsArray
|
||||
{
|
||||
// databaseObject.versions post-merge doesn't match contextApp.versions pre-merge, so attempt to fix by re-sorting.
|
||||
|
||||
let fixedAppVersions = databaseObject.versions.sorted { (versionA, versionB) in
|
||||
let fixedAppVersions = databaseObject.versions.sorted { (versionA, versionB) in
|
||||
let indexA = sortedAppVersionIDs.index(of: versionA.versionID)
|
||||
let indexB = sortedAppVersionIDs.index(of: versionB.versionID)
|
||||
return indexA < indexB
|
||||
@@ -387,16 +387,19 @@ extension MergePolicy{
|
||||
}
|
||||
|
||||
appVersions = fixedAppVersions
|
||||
|
||||
// Always update versions post-merging to make sure latestSupportedVersion is correct.
|
||||
try databaseObject.setVersions(appVersions)
|
||||
}
|
||||
|
||||
// Screenshots
|
||||
if let sortedScreenshotIDs = sortedScreenshotIDsByGlobalAppID[globallyUniqueID],
|
||||
let sortedScreenshotIDsArray = sortedScreenshotIDs.array as? [String],
|
||||
case let databaseScreenshotIDs = databaseObject.allScreenshots.map({ $0.screenshotID }),
|
||||
case let databaseScreenshotIDs = databaseObject.allScreenshots.map({ $0.screenshotID }),
|
||||
databaseScreenshotIDs != sortedScreenshotIDsArray
|
||||
{
|
||||
// Screenshot order is incorrect, so attempt to fix by re-sorting.
|
||||
let fixedScreenshots = databaseObject.allScreenshots.sorted { (screenshotA, screenshotB) in
|
||||
let fixedScreenshots = databaseObject.allScreenshots.sorted { (screenshotA, screenshotB) in
|
||||
let indexA = sortedScreenshotIDs.index(of: screenshotA.screenshotID)
|
||||
let indexB = sortedScreenshotIDs.index(of: screenshotB.screenshotID)
|
||||
return indexA < indexB
|
||||
@@ -415,8 +418,6 @@ extension MergePolicy{
|
||||
}
|
||||
}
|
||||
|
||||
// Always update versions post-merging to make sure latestSupportedVersion is correct.
|
||||
try databaseObject.setVersions(appVersions)
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -33,172 +33,171 @@ public extension Source
|
||||
#endif
|
||||
}
|
||||
|
||||
public struct AppPermissionFeed: Codable {
|
||||
let type: String // ALTAppPermissionType
|
||||
let usageDescription: String
|
||||
// public struct AppPermissionFeed: Codable {
|
||||
// let type: String // ALTAppPermissionType
|
||||
// let usageDescription: String
|
||||
|
||||
enum CodingKeys: String, CodingKey
|
||||
{
|
||||
case type
|
||||
case usageDescription
|
||||
}
|
||||
}
|
||||
// enum CodingKeys: String, CodingKey
|
||||
// {
|
||||
// case type
|
||||
// case usageDescription
|
||||
// }
|
||||
// }
|
||||
|
||||
public struct AppVersionFeed: Codable {
|
||||
/* Properties */
|
||||
let version: String
|
||||
let date: Date
|
||||
let localizedDescription: String?
|
||||
// public struct AppVersionFeed: Codable {
|
||||
// /* Properties */
|
||||
// let version: String
|
||||
// let date: Date
|
||||
// let localizedDescription: String?
|
||||
|
||||
let downloadURL: URL
|
||||
let size: Int64
|
||||
// added in 0.6.0
|
||||
let sha256: String? // sha 256 of the uploaded IPA
|
||||
// let downloadURL: URL
|
||||
// let size: Int64
|
||||
// // added in 0.6.0
|
||||
// let sha256: String? // sha 256 of the uploaded IPA
|
||||
|
||||
enum CodingKeys: String, CodingKey
|
||||
{
|
||||
case version
|
||||
case date
|
||||
case localizedDescription
|
||||
case downloadURL
|
||||
case size
|
||||
// added in 0.6.0
|
||||
case sha256
|
||||
}
|
||||
}
|
||||
// enum CodingKeys: String, CodingKey
|
||||
// {
|
||||
// case version
|
||||
// case date
|
||||
// case localizedDescription
|
||||
// case downloadURL
|
||||
// case size
|
||||
// // added in 0.6.0
|
||||
// case sha256
|
||||
// }
|
||||
// }
|
||||
|
||||
public struct PlatformURLFeed: Codable {
|
||||
/* Properties */
|
||||
let platform: Platform
|
||||
let downloadURL: URL
|
||||
// public struct PlatformURLFeed: Codable {
|
||||
// /* Properties */
|
||||
// let platform: Platform
|
||||
// let downloadURL: URL
|
||||
|
||||
|
||||
private enum CodingKeys: String, CodingKey
|
||||
{
|
||||
case platform
|
||||
case downloadURL
|
||||
}
|
||||
}
|
||||
// private enum CodingKeys: String, CodingKey
|
||||
// {
|
||||
// case platform
|
||||
// case downloadURL
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public struct StoreAppFeed: Codable {
|
||||
let name: String
|
||||
let bundleIdentifier: String
|
||||
let subtitle: String?
|
||||
// public struct StoreAppFeed: Codable {
|
||||
// let name: String
|
||||
// let bundleIdentifier: String
|
||||
// let subtitle: String?
|
||||
|
||||
let developerName: String
|
||||
let localizedDescription: String
|
||||
let size: Int64
|
||||
// let developerName: String
|
||||
// let localizedDescription: String
|
||||
// let size: Int64
|
||||
|
||||
let iconURL: URL
|
||||
let screenshotURLs: [URL]
|
||||
// let iconURL: URL
|
||||
// let screenshotURLs: [URL]
|
||||
|
||||
let version: String
|
||||
let versionDate: Date
|
||||
let versionDescription: String?
|
||||
let downloadURL: URL
|
||||
let platformURLs: [PlatformURLFeed]?
|
||||
// let version: String
|
||||
// let versionDate: Date
|
||||
// let versionDescription: String?
|
||||
// let downloadURL: URL
|
||||
// let platformURLs: [PlatformURLFeed]?
|
||||
|
||||
let tintColor: String? // UIColor?
|
||||
let isBeta: Bool
|
||||
// let tintColor: String? // UIColor?
|
||||
// let isBeta: Bool
|
||||
|
||||
// let source: Source?
|
||||
let appPermissions: [AppPermissionFeed]
|
||||
let versions: [AppVersionFeed]
|
||||
// // let source: Source?
|
||||
// let appPermissions: [AppPermissionFeed]
|
||||
// let versions: [AppVersionFeed]
|
||||
|
||||
enum CodingKeys: String, CodingKey
|
||||
{
|
||||
case bundleIdentifier
|
||||
case developerName
|
||||
case downloadURL
|
||||
case iconURL
|
||||
case isBeta = "beta"
|
||||
case localizedDescription
|
||||
case name
|
||||
case appPermissions
|
||||
case platformURLs
|
||||
case screenshotURLs
|
||||
case size
|
||||
case subtitle
|
||||
case tintColor
|
||||
case version
|
||||
case versionDate
|
||||
case versionDescription
|
||||
case versions
|
||||
}
|
||||
}
|
||||
// enum CodingKeys: String, CodingKey
|
||||
// {
|
||||
// case bundleIdentifier
|
||||
// case developerName
|
||||
// case downloadURL
|
||||
// case iconURL
|
||||
// case isBeta = "beta"
|
||||
// case localizedDescription
|
||||
// case name
|
||||
// case appPermissions
|
||||
// case platformURLs
|
||||
// case screenshotURLs
|
||||
// case size
|
||||
// case subtitle
|
||||
// case tintColor
|
||||
// case version
|
||||
// case versionDate
|
||||
// case versionDescription
|
||||
// case versions
|
||||
// }
|
||||
// }
|
||||
|
||||
public struct NewsItemFeed: Codable {
|
||||
let identifier: String
|
||||
let date: Date
|
||||
// public struct NewsItemFeed: Codable {
|
||||
// let identifier: String
|
||||
// let date: Date
|
||||
|
||||
let title: String
|
||||
let caption: String
|
||||
let tintColor: String //UIColor
|
||||
let notify: Bool
|
||||
// let title: String
|
||||
// let caption: String
|
||||
// let tintColor: String //UIColor
|
||||
// let notify: Bool
|
||||
|
||||
let imageURL: URL?
|
||||
let externalURL: URL?
|
||||
// let imageURL: URL?
|
||||
// let externalURL: URL?
|
||||
|
||||
let appID: String?
|
||||
// let appID: String?
|
||||
|
||||
private enum CodingKeys: String, CodingKey
|
||||
{
|
||||
case identifier
|
||||
case date
|
||||
case title
|
||||
case caption
|
||||
case tintColor
|
||||
case imageURL
|
||||
case externalURL = "url"
|
||||
case appID
|
||||
case notify
|
||||
}
|
||||
}
|
||||
// private enum CodingKeys: String, CodingKey
|
||||
// {
|
||||
// case identifier
|
||||
// case date
|
||||
// case title
|
||||
// case caption
|
||||
// case tintColor
|
||||
// case imageURL
|
||||
// case externalURL = "url"
|
||||
// case appID
|
||||
// case notify
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public struct SourceJSON: Codable {
|
||||
let version: Int?
|
||||
let name: String
|
||||
let identifier: String
|
||||
let sourceURL: URL
|
||||
let userInfo: [String:String]? //[ALTSourceUserInfoKey:String]?
|
||||
let apps: [StoreAppFeed]
|
||||
let news: [NewsItemFeed]
|
||||
// public struct SourceJSON: Codable {
|
||||
// let version: Int?
|
||||
// let name: String
|
||||
// let identifier: String
|
||||
// let sourceURL: URL
|
||||
// let userInfo: [String:String]? //[ALTSourceUserInfoKey:String]?
|
||||
// let apps: [StoreAppFeed]
|
||||
// let news: [NewsItemFeed]
|
||||
|
||||
enum CodingKeys: String, CodingKey
|
||||
{
|
||||
case version
|
||||
case name
|
||||
case identifier
|
||||
case sourceURL
|
||||
case userInfo
|
||||
case apps
|
||||
case news
|
||||
}
|
||||
|
||||
}
|
||||
// enum CodingKeys: String, CodingKey
|
||||
// {
|
||||
// case version
|
||||
// case name
|
||||
// case identifier
|
||||
// case sourceURL
|
||||
// case userInfo
|
||||
// case apps
|
||||
// case news
|
||||
// }
|
||||
// }
|
||||
|
||||
public extension Source
|
||||
{
|
||||
// Fallbacks for optional JSON values.
|
||||
public extension Source
|
||||
{
|
||||
// Fallbacks for optional JSON values.
|
||||
|
||||
var effectiveIconURL: URL? {
|
||||
return self.iconURL ?? self.apps.first?.iconURL
|
||||
}
|
||||
var effectiveIconURL: URL? {
|
||||
return self.iconURL ?? self.apps.first?.iconURL
|
||||
}
|
||||
|
||||
var effectiveHeaderImageURL: URL? {
|
||||
return self.headerImageURL ?? self.effectiveIconURL
|
||||
}
|
||||
var effectiveHeaderImageURL: URL? {
|
||||
return self.headerImageURL ?? self.effectiveIconURL
|
||||
}
|
||||
|
||||
var effectiveTintColor: UIColor? {
|
||||
return self.tintColor ?? self.apps.first?.tintColor
|
||||
}
|
||||
var effectiveTintColor: UIColor? {
|
||||
return self.tintColor ?? self.apps.first?.tintColor
|
||||
}
|
||||
|
||||
var effectiveFeaturedApps: [StoreApp] {
|
||||
return self.featuredApps ?? self.apps
|
||||
}
|
||||
}
|
||||
var effectiveFeaturedApps: [StoreApp] {
|
||||
return self.featuredApps ?? self.apps
|
||||
}
|
||||
}
|
||||
|
||||
@objc(Source)
|
||||
public class Source: BaseEntity, Decodable
|
||||
|
||||
Reference in New Issue
Block a user