mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-25 11:22:23 +00:00
Improved version checking
This commit is contained in:
parent
c39abf08ae
commit
79c49487e2
1 changed files with 19 additions and 1 deletions
|
@ -41,12 +41,30 @@ class _BaseState extends State<Base> with WidgetsBindingObserver {
|
||||||
|
|
||||||
final PermissionHandlerPlatform permissionHandler = PermissionHandlerPlatform.instance;
|
final PermissionHandlerPlatform permissionHandler = PermissionHandlerPlatform.instance;
|
||||||
|
|
||||||
|
bool updateExists(String appVersion, String gitHubVersion) {
|
||||||
|
final List<int> appVersionSplit = List<int>.from(appVersion.split('.').map((e) => int.parse(e)));
|
||||||
|
final List<int> gitHubVersionSplit = List<int>.from(gitHubVersion.split('.').map((e) => int.parse(e)));
|
||||||
|
|
||||||
|
if (gitHubVersionSplit[0] > appVersionSplit[0]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (gitHubVersionSplit[0] == appVersionSplit[0] && gitHubVersionSplit[1] > appVersionSplit[1]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (gitHubVersionSplit[0] == appVersionSplit[0] && gitHubVersionSplit[1] == appVersionSplit[1] && gitHubVersionSplit[2] > appVersionSplit[2]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<GitHubRelease?> checkInstallationSource() async {
|
Future<GitHubRelease?> checkInstallationSource() async {
|
||||||
Source installationSource = await StoreChecker.getSource;
|
Source installationSource = await StoreChecker.getSource;
|
||||||
if (installationSource != Source.IS_INSTALLED_FROM_PLAY_STORE) {
|
if (installationSource != Source.IS_INSTALLED_FROM_PLAY_STORE) {
|
||||||
final result = await checkAppUpdatesGitHub();
|
final result = await checkAppUpdatesGitHub();
|
||||||
if (result['result'] == 'success') {
|
if (result['result'] == 'success') {
|
||||||
if (result['body'].tagName != widget.appConfigProvider.getAppInfo!.version) {
|
if (updateExists(widget.appConfigProvider.getAppInfo!.version, result['body'].tagName)) {
|
||||||
return result['body'];
|
return result['body'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue