Skip to content

Commit

Permalink
[update] fixed version comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Sep 23, 2024
1 parent 5bacd17 commit 188fa87
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/backend/update/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Future<void> _checkAppUpdate({
await Future.delayed(delayAtLeast);
}
if (!context.mounted) return;
if (latest.version > currentVersion) {
if (latest.version.compareToIncludingBuild(currentVersion) > 0) {
await context.showSheet(
(ctx) => ArtifactUpdatePage(info: latest),
dismissible: false,
Expand All @@ -74,6 +74,24 @@ Future<void> _checkAppUpdate({
}
}

extension VersionEx on Version {
int compareToIncludingBuild(Version other) {
final result = compareTo(other);
if (result == 0) {
final thisBuild = int.tryParse(build);
final otherBuild = int.tryParse(other.build);
if (thisBuild != null && otherBuild == null) {
return 1;
} else if (thisBuild == null && otherBuild != null) {
return -1;
} else if (thisBuild != null && otherBuild != null) {
return thisBuild.compareTo(otherBuild);
}
}
return result;
}
}

Version? _getSkippedVersion() {
final skippedVersionRaw = Settings.update.skippedVersion;
if (skippedVersionRaw != null) {
Expand Down

0 comments on commit 188fa87

Please sign in to comment.