-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
29 additions
and
50 deletions.
There are no files selected for viewing
31 changes: 14 additions & 17 deletions
31
UnstoppableWallet/UnstoppableWallet/Core/Managers/AppVersionManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
import Foundation | ||
import RxSwift | ||
import RxRelay | ||
import RxSwift | ||
|
||
class AppVersionManager { | ||
private let systemInfoManager: SystemInfoManager | ||
private let storage: AppVersionStorage | ||
|
||
var newVersion: AppVersion? { | ||
let currentVersion = systemInfoManager.appVersion | ||
|
||
guard let lastVersion = storage.appVersions.last, currentVersion > lastVersion else { | ||
return nil | ||
} | ||
|
||
return currentVersion | ||
} | ||
|
||
func updateStoredVersion() { | ||
func checkVersionUpdate() -> AppVersion? { | ||
let currentVersion = systemInfoManager.appVersion | ||
|
||
// first start | ||
guard let lastVersion = storage.appVersions.last else { | ||
storage.save(appVersions: [currentVersion]) | ||
return | ||
return nil | ||
} | ||
|
||
if lastVersion.version != currentVersion.version || lastVersion.build != currentVersion.build { | ||
switch currentVersion.change(lastVersion) { | ||
// show release | ||
case .version: | ||
storage.save(appVersions: [currentVersion]) | ||
return currentVersion | ||
// just update db | ||
case .build, .downgrade: | ||
storage.save(appVersions: [currentVersion]) | ||
case .none: () | ||
} | ||
|
||
return nil | ||
} | ||
|
||
init(systemInfoManager: SystemInfoManager, storage: AppVersionStorage) { | ||
self.systemInfoManager = systemInfoManager | ||
self.storage = storage | ||
} | ||
|
||
} | ||
|
||
extension AppVersionManager { | ||
|
||
var currentVersion: AppVersion { | ||
systemInfoManager.appVersion | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters