From 07c490bb0e5897c419eef090d1b8ccd5bbab4200 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sat, 25 Mar 2023 00:47:26 -0400 Subject: [PATCH 1/3] Fixed "return after delete" bug (#359) --- lib/main.dart | 2 +- lib/pages/add_app.dart | 2 +- lib/providers/apps_provider.dart | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 9d7f7ad..3ad511e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -210,7 +210,7 @@ class _ObtainiumState extends State { {'includePrereleases': true}, null, false) - ]); + ], onlyIfExists: false); } if (!supportedLocales .map((e) => e.languageCode) diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index f68ae3c..0138db1 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -149,7 +149,7 @@ class _AddAppPageState extends State { app.installedVersion = app.latestVersion; } app.categories = pickedCategories; - await appsProvider.saveApps([app]); + await appsProvider.saveApps([app], onlyIfExists: false); return app; } diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index f3069df..572f40b 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -628,7 +628,8 @@ class AppsProvider with ChangeNotifier { } Future saveApps(List apps, - {bool attemptToCorrectInstallStatus = true}) async { + {bool attemptToCorrectInstallStatus = true, + bool onlyIfExists = true}) async { attemptToCorrectInstallStatus = attemptToCorrectInstallStatus && (await doesInstalledAppsPluginWork()); for (var app in apps) { @@ -639,9 +640,15 @@ class AppsProvider with ChangeNotifier { } File('${(await getAppsDir()).path}/${app.id}.json') .writeAsStringSync(jsonEncode(app.toJson())); - this.apps.update( - app.id, (value) => AppInMemory(app, value.downloadProgress, info), - ifAbsent: () => AppInMemory(app, null, info)); + try { + this.apps.update( + app.id, (value) => AppInMemory(app, value.downloadProgress, info), + ifAbsent: onlyIfExists ? null : () => AppInMemory(app, null, info)); + } catch (e) { + if (e is! ArgumentError || e.name != 'key') { + rethrow; + } + } } notifyListeners(); } @@ -824,7 +831,7 @@ class AppsProvider with ChangeNotifier { a.installedVersion = apps[a.id]?.app.installedVersion; } } - await saveApps(importedApps); + await saveApps(importedApps, onlyIfExists: false); notifyListeners(); return importedApps.length; } @@ -844,7 +851,7 @@ class AppsProvider with ChangeNotifier { if (apps.containsKey(app.id)) { errorsMap.addAll({app.id: tr('appAlreadyAdded')}); } else { - await saveApps([app]); + await saveApps([app], onlyIfExists: false); } } List> errors = From 4c04af38689f1d0486211cd49235f20ea669fb64 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sat, 25 Mar 2023 00:54:12 -0400 Subject: [PATCH 2/3] Bugfix: App add doesn't redirect if nav away during add --- lib/pages/add_app.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index 0138db1..a2e3cda 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -156,7 +156,7 @@ class _AddAppPageState extends State { }() .then((app) { if (app != null) { - Navigator.push(context, + Navigator.push(globalNavigatorKey.currentContext ?? context, MaterialPageRoute(builder: (context) => AppPage(appId: app.id))); } }).catchError((e) { From 895deeead5b94a4909c8ec8a887781d9b4f81a87 Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Sat, 25 Mar 2023 00:54:34 -0400 Subject: [PATCH 3/3] Increment version --- lib/main.dart | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 3ad511e..e88a276 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.11.13'; +const String currentVersion = '0.11.14'; const String currentReleaseTag = 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES diff --git a/pubspec.yaml b/pubspec.yaml index d546491..76f4868 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.11.13+134 # When changing this, update the tag in main() accordingly +version: 0.11.14+135 # When changing this, update the tag in main() accordingly environment: sdk: '>=2.18.2 <3.0.0'