fix: Update dialog shows dev version & loading gets stuck in certain circumstances (#1792)

Signed-off-by: validcube <pun.butrach@gmail.com>
Co-authored-by: validcube <pun.butrach@gmail.com>
This commit is contained in:
kitadai31
2024-06-19 16:44:09 +09:00
committed by GitHub
parent 46f6a49a7a
commit fc52560244
3 changed files with 114 additions and 121 deletions

View File

@ -39,7 +39,8 @@ class HomeViewModel extends BaseViewModel {
List<PatchedApplication> patchedInstalledApps = [];
String _currentManagerVersion = '';
String _currentPatchesVersion = '';
String? _latestManagerVersion = '';
String? latestManagerVersion;
String? latestPatchesVersion;
File? downloadedApk;
Future<void> initialize(BuildContext context) async {
@ -50,7 +51,6 @@ class HomeViewModel extends BaseViewModel {
await forceRefresh(context);
return;
}
_latestManagerVersion = await _managerAPI.getLatestManagerVersion();
_currentPatchesVersion = await _managerAPI.getCurrentPatchesVersion();
if (_managerAPI.showUpdateDialog() && await hasManagerUpdates()) {
showUpdateDialog(context, false);
@ -131,21 +131,21 @@ class HomeViewModel extends BaseViewModel {
if (!_managerAPI.releaseBuild) {
return false;
}
_latestManagerVersion =
latestManagerVersion =
await _managerAPI.getLatestManagerVersion() ?? _currentManagerVersion;
if (_latestManagerVersion != _currentManagerVersion) {
if (latestManagerVersion != _currentManagerVersion) {
return true;
}
return false;
}
Future<bool> hasPatchesUpdates() async {
final String? latestVersion = await _managerAPI.getLatestPatchesVersion();
if (latestVersion != null) {
latestPatchesVersion = await _managerAPI.getLatestPatchesVersion();
if (latestPatchesVersion != null) {
try {
final int latestVersionInt =
int.parse(latestVersion.replaceAll(RegExp('[^0-9]'), ''));
int.parse(latestPatchesVersion!.replaceAll(RegExp('[^0-9]'), ''));
final int currentVersionInt =
int.parse(_currentPatchesVersion.replaceAll(RegExp('[^0-9]'), ''));
return latestVersionInt > currentVersionInt;
@ -475,12 +475,14 @@ class HomeViewModel extends BaseViewModel {
);
}
Future<Map<String, dynamic>?> getLatestManagerRelease() {
return _githubAPI.getLatestManagerRelease(_managerAPI.defaultManagerRepo);
Future<String?> getManagerChangelogs() {
return _githubAPI.getManagerChangelogs();
}
Future<Map<String, dynamic>?> getLatestPatchesRelease() {
return _githubAPI.getLatestRelease(_managerAPI.defaultPatchesRepo);
Future<String?> getLatestPatchesChangelog() async {
final release =
await _githubAPI.getLatestRelease(_managerAPI.defaultPatchesRepo);
return release?['body'];
}
Future<String?> getLatestPatchesReleaseTime() {