updated localstore collection to global constant

This commit is contained in:
2024-04-16 14:39:20 +02:00
parent 19aca8f97f
commit f5407d2477
16 changed files with 24 additions and 23 deletions

View File

@ -11,6 +11,8 @@ abstract class RequestCache<T extends ApiResponse?> {
static const int cacheHour = 60 * 60;
static const int cacheDay = 60 * 60 * 24;
static String collection = 'MarianumMobile';
int maxCacheTime;
Function(T) onUpdate;
Function(Exception) onError;
@ -20,8 +22,8 @@ abstract class RequestCache<T extends ApiResponse?> {
static void ignore(Exception e) {}
Future<void> start(String file, String document) async {
var tableData = await Localstore.instance.collection(file).doc(document).get();
Future<void> start(String document) async {
var tableData = await Localstore.instance.collection(collection).doc(document).get();
if(tableData != null) {
onUpdate(onLocalData(tableData['json']));
}
@ -34,7 +36,7 @@ abstract class RequestCache<T extends ApiResponse?> {
var newValue = await onLoad();
onUpdate(newValue);
Localstore.instance.collection(file).doc(document).set({
Localstore.instance.collection(collection).doc(document).set({
'json': jsonEncode(newValue),
'lastupdate': DateTime.now().millisecondsSinceEpoch
});