Skip to content

Commit

Permalink
Upgrade core to check new release api
Browse files Browse the repository at this point in the history
  • Loading branch information
gemcoder21 committed Sep 24, 2024
1 parent 3899e3b commit 617c835
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
19 changes: 11 additions & 8 deletions Gem/Core/Services/OnstartAsyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class OnstartAsyncService {
}
}
}

if versions.swapAssets > preferences.swapAssetsVersion {
Task {
do {
Expand All @@ -90,18 +90,21 @@ class OnstartAsyncService {
}
}
}

let newVersion = config.app.ios.version.production
if VersionCheck.isVersionHigher(new: newVersion, current: Bundle.main.releaseVersionNumber) {
NSLog("Newer version available")
updateVersionAction?(newVersion)
#if RELEASE
if let newVersion = config.releases.first(where: { $0.store == .appStore }),
VersionCheck.isVersionHigher(new: newVersion.version, current: Bundle.main.releaseVersionNumber) {
NSLog("Newer version available")
updateVersionAction?(newVersion.version)
}
#endif
} catch {
NSLog("Fetching config error: \(error)")
}


#if RELEASE
RateService().perform()

#endif

Task {
try await deviceService.update()
}
Expand Down
16 changes: 15 additions & 1 deletion Packages/Primitives/Sources/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ public struct ConfigApp: Codable {
}
}

public struct Release: Codable {
public let version: String
public let store: PlatformStore
public let upgrade_required: Bool

public init(version: String, store: PlatformStore, upgrade_required: Bool) {
self.version = version
self.store = store
self.upgrade_required = upgrade_required
}
}

public struct ConfigVersions: Codable {
public let fiatAssets: Int32
public let swapAssets: Int32
Expand All @@ -54,10 +66,12 @@ public struct ConfigVersions: Codable {

public struct ConfigResponse: Codable {
public let app: ConfigApp
public let releases: [Release]
public let versions: ConfigVersions

public init(app: ConfigApp, versions: ConfigVersions) {
public init(app: ConfigApp, releases: [Release], versions: ConfigVersions) {
self.app = app
self.releases = releases
self.versions = versions
}
}
10 changes: 10 additions & 0 deletions Packages/Primitives/Sources/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@ public enum Platform: String, Codable, Equatable {
case ios
case android
}

public enum PlatformStore: String, Codable, CaseIterable, Equatable {
case appStore
case googlePlay
case fdroid
case huawei
case solanaDAppStore
case samsungStore
case apkUniversal
}

0 comments on commit 617c835

Please sign in to comment.