mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Parses AppVersion.minOSVersion/maxOSVersion from source JSON
This commit is contained in:
@@ -54,6 +54,8 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable
|
|||||||
case localizedDescription
|
case localizedDescription
|
||||||
case downloadURL
|
case downloadURL
|
||||||
case size
|
case size
|
||||||
|
case minOSVersion
|
||||||
|
case maxOSVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
public required init(from decoder: Decoder) throws
|
public required init(from decoder: Decoder) throws
|
||||||
@@ -72,6 +74,9 @@ public class AppVersion: NSManagedObject, Decodable, Fetchable
|
|||||||
|
|
||||||
self.downloadURL = try container.decode(URL.self, forKey: .downloadURL)
|
self.downloadURL = try container.decode(URL.self, forKey: .downloadURL)
|
||||||
self.size = try container.decode(Int64.self, forKey: .size)
|
self.size = try container.decode(Int64.self, forKey: .size)
|
||||||
|
|
||||||
|
self._minOSVersion = try container.decodeIfPresent(String.self, forKey: .minOSVersion)
|
||||||
|
self._maxOSVersion = try container.decodeIfPresent(String.self, forKey: .maxOSVersion)
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -115,6 +120,11 @@ public extension AppVersion
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isSupported: Bool {
|
var isSupported: Bool {
|
||||||
|
if let minOSVersion = self.minOSVersion, !ProcessInfo.processInfo.isOperatingSystemAtLeast(minOSVersion) {
|
||||||
|
return false
|
||||||
|
} else if let maxOSVersion = self.maxOSVersion, ProcessInfo.processInfo.operatingSystemVersion > maxOSVersion {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user