🐛 Fix upgrade detection method

This commit is contained in:
LittleSheep 2024-09-18 20:27:13 +08:00
parent fb370a484d
commit 0cc842c030
2 changed files with 10 additions and 3 deletions

View File

@ -60,12 +60,19 @@ class _BootstrapperShellState extends State<BootstrapperShell> {
'https://git.solsynth.dev/api/v1/repos/hydrogen/solian/tags?page=1&limit=1', 'https://git.solsynth.dev/api/v1/repos/hydrogen/solian/tags?page=1&limit=1',
); );
final remoteVersionString = final remoteVersionString =
(resp.body as List).firstOrNull?['name'] ?? '0.0.0'; (resp.body as List).firstOrNull?['name'] ?? '0.0.0+0';
final remoteVersion = Version.parse(remoteVersionString ?? '0.0.0'); final remoteVersion =
Version.parse(remoteVersionString.split('+').first);
final localVersion = final localVersion =
Version.parse(localVersionString.split('+').first); Version.parse(localVersionString.split('+').first);
final remoteBuildNumber =
int.tryParse(remoteVersionString.split('+').last) ?? 0;
final localBuildNumber =
int.tryParse(localVersionString.split('+').last) ?? 0;
final strictUpdate = prefs.getBool('check_update_strictly') ?? false; final strictUpdate = prefs.getBool('check_update_strictly') ?? false;
if (remoteVersion > localVersion || if (remoteVersion > localVersion ||
(remoteVersion == localVersion &&
remoteBuildNumber > localBuildNumber) ||
(remoteVersionString != localVersionString && strictUpdate)) { (remoteVersionString != localVersionString && strictUpdate)) {
setState(() { setState(() {
_isErrored = true; _isErrored = true;

View File

@ -2,7 +2,7 @@ name: solian
description: "The Solar Network App" description: "The Solar Network App"
publish_to: "none" publish_to: "none"
version: 1.2.2+2 version: 1.2.2+3
environment: environment:
sdk: ">=3.3.4 <4.0.0" sdk: ">=3.3.4 <4.0.0"