WIP high education graduation calculator
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:localstore/localstore.dart';
|
||||
|
||||
import 'apiResponse.dart';
|
||||
import 'webuntis/webuntisError.dart';
|
||||
|
||||
abstract class RequestCache<T extends ApiResponse?> {
|
||||
static const int cacheNothing = 0;
|
||||
@ -30,16 +30,18 @@ abstract class RequestCache<T extends ApiResponse?> {
|
||||
if(renew == null || !renew!) return;
|
||||
}
|
||||
|
||||
T? newValue;
|
||||
try {
|
||||
T newValue = await onLoad();
|
||||
onUpdate(newValue);
|
||||
newValue = await onLoad();
|
||||
onUpdate(newValue as T);
|
||||
|
||||
Localstore.instance.collection(file).doc(document).set({
|
||||
"json": jsonEncode(newValue),
|
||||
"lastupdate": DateTime.now().millisecondsSinceEpoch
|
||||
});
|
||||
} on WebuntisError catch(e) {
|
||||
onError(e);
|
||||
} catch(e) {
|
||||
log("Error while fetching/ parsing. Raw server response: ${newValue?.rawResponse.body ?? "no response"}");
|
||||
onError(Exception(e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user