Fix installed version bug when importing apps (#1179)

This commit is contained in:
Imran Remtulla
2023-12-22 21:10:11 -05:00
parent cdccf58b76
commit 2a4cc35df7

View File

@@ -740,12 +740,15 @@ class AppsProvider with ChangeNotifier {
return appsDir; return appsDir;
} }
Future<PackageInfo?> getInstalledInfo(String? packageName) async { Future<PackageInfo?> getInstalledInfo(String? packageName,
{bool printErr = true}) async {
if (packageName != null) { if (packageName != null) {
try { try {
return await pm.getPackageInfo(packageName: packageName); return await pm.getPackageInfo(packageName: packageName);
} catch (e) { } catch (e) {
print(e); // OK if (printErr) {
print(e); // OK
}
} }
} }
return null; return null;
@@ -1253,9 +1256,8 @@ class AppsProvider with ChangeNotifier {
await Future.delayed(const Duration(microseconds: 1)); await Future.delayed(const Duration(microseconds: 1));
} }
for (App a in importedApps) { for (App a in importedApps) {
if (apps[a.id]?.app.installedVersion != null) { a.installedVersion =
a.installedVersion = apps[a.id]?.app.installedVersion; (await getInstalledInfo(a.id, printErr: false))?.versionName;
}
} }
await saveApps(importedApps, onlyIfExists: false); await saveApps(importedApps, onlyIfExists: false);
notifyListeners(); notifyListeners();