Bugfix for installing apps with ID change step (#1424)

This commit is contained in:
Imran Remtulla
2024-03-01 19:46:30 -05:00
parent 1cfb258dcc
commit f66753498b

View File

@@ -717,7 +717,7 @@ class AppsProvider with ChangeNotifier {
appsToInstall = appsToInstall =
moveStrToEnd(appsToInstall, obtainiumId, strB: obtainiumTempId); moveStrToEnd(appsToInstall, obtainiumId, strB: obtainiumTempId);
Future<void> updateFn(String id, {bool skipInstalls = false}) async { Future<String> updateFn(String id, {bool skipInstalls = false}) async {
try { try {
var downloadedArtifact = var downloadedArtifact =
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
@@ -730,8 +730,8 @@ class AppsProvider with ChangeNotifier {
} else { } else {
downloadedDir = downloadedArtifact as DownloadedXApkDir; downloadedDir = downloadedArtifact as DownloadedXApkDir;
} }
var appId = downloadedFile?.appId ?? downloadedDir!.appId; id = downloadedFile?.appId ?? downloadedDir!.appId;
bool willBeSilent = await canInstallSilently(apps[appId]!.app); bool willBeSilent = await canInstallSilently(apps[id]!.app);
switch (settingsProvider.installMethod) { switch (settingsProvider.installMethod) {
case InstallMethodSettings.normal: case InstallMethodSettings.normal:
if (!(await settingsProvider.getInstallPermission( if (!(await settingsProvider.getInstallPermission(
@@ -773,18 +773,19 @@ class AppsProvider with ChangeNotifier {
} }
if (willBeSilent && context == null) { if (willBeSilent && context == null) {
notificationsProvider?.notify(SilentUpdateAttemptNotification( notificationsProvider?.notify(SilentUpdateAttemptNotification(
[apps[appId]!.app], [apps[id]!.app],
id: appId.hashCode)); id: id.hashCode));
} }
installedIds.add(id);
} }
} finally { } finally {
apps[id]?.downloadProgress = null; apps[id]?.downloadProgress = null;
notifyListeners(); notifyListeners();
} }
installedIds.add(id);
} catch (e) { } catch (e) {
errors.add(id, e, appName: apps[id]?.name); errors.add(id, e, appName: apps[id]?.name);
} }
return id;
} }
if (forceParallelDownloads || !settingsProvider.parallelDownloads) { if (forceParallelDownloads || !settingsProvider.parallelDownloads) {
@@ -792,9 +793,9 @@ class AppsProvider with ChangeNotifier {
await updateFn(id); await updateFn(id);
} }
} else { } else {
await Future.wait( List<String> ids = await Future.wait(
appsToInstall.map((id) => updateFn(id, skipInstalls: true))); appsToInstall.map((id) => updateFn(id, skipInstalls: true)));
for (var id in appsToInstall) { for (var id in ids) {
if (!errors.appIdNames.containsKey(id)) { if (!errors.appIdNames.containsKey(id)) {
await updateFn(id); await updateFn(id);
} }