Skip to content

Commit

Permalink
More informative errors for mass update checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Imran Remtulla committed Oct 11, 2022
1 parent 03f0b6c commit 52ce5b1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:dynamic_color/dynamic_color.dart';
import 'package:device_info_plus/device_info_plus.dart';

const String currentReleaseTag =
'v0.5.8-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
'v0.5.9-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES

const String bgUpdateCheckTaskName = 'bg-update-check';

Expand Down
20 changes: 19 additions & 1 deletion lib/providers/apps_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ class AppsProvider with ChangeNotifier {

Future<List<App>> checkUpdates({DateTime? ignoreAfter}) async {
List<App> updates = [];
Map<String, List<String>> errors = {};
if (!gettingUpdates) {
gettingUpdates = true;

Expand All @@ -340,14 +341,31 @@ class AppsProvider with ChangeNotifier {
DateTime.fromMicrosecondsSinceEpoch(0))
.compareTo(apps[b]!.app.lastUpdateCheck ??
DateTime.fromMicrosecondsSinceEpoch(0)));

for (int i = 0; i < appIds.length; i++) {
App? newApp = await getUpdate(appIds[i]);
App? newApp;
try {
newApp = await getUpdate(appIds[i]);
} catch (e) {
var tempIds = errors.remove(e.toString());
tempIds ??= [];
tempIds.add(appIds[i]);
errors.putIfAbsent(e.toString(), () => tempIds!);
}
if (newApp != null) {
updates.add(newApp);
}
}
gettingUpdates = false;
}
if (errors.isNotEmpty) {
String finalError = '';
for (var e in errors.keys) {
finalError +=
'$e ${errors[e]!.map((e) => apps[e]!.app.name).toString()}. ';
}
throw finalError;
}
return updates;
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.5.8+29 # When changing this, update the tag in main() accordingly
version: 0.5.9+30 # When changing this, update the tag in main() accordingly

environment:
sdk: '>=2.19.0-79.0.dev <3.0.0'
Expand Down

0 comments on commit 52ce5b1

Please sign in to comment.