Update checking improvements (#38)

Still no auto retry for rate-limit. Instead, rate-limit errors are ignored and the unchecked Apps have to wait until the next cycle. Even this needs more testing before release.
This commit is contained in:
Imran Remtulla
2022-09-27 23:20:39 -04:00
committed by GitHub
parent 77e1768f3b
commit dd193d62f2
10 changed files with 185 additions and 90 deletions

View File

@ -297,12 +297,23 @@ class AppsProvider with ChangeNotifier {
return null;
}
Future<List<App>> checkUpdates() async {
Future<List<App>> checkUpdates({DateTime? ignoreAfter}) async {
List<App> updates = [];
if (!gettingUpdates) {
gettingUpdates = true;
List<String> appIds = apps.keys.toList();
if (ignoreAfter != null) {
appIds = appIds
.where((id) =>
apps[id]!.app.lastUpdateCheck != null &&
apps[id]!.app.lastUpdateCheck!.isBefore(ignoreAfter))
.toList();
}
appIds.sort((a, b) => (apps[a]!.app.lastUpdateCheck ??
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]);
if (newApp != null) {