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

@ -8,21 +8,21 @@ import 'package:jiffy/jiffy.dart';
import 'package:localstore/localstore.dart';
import '../../../widget/placeholderView.dart';
import '../../api/requestCache.dart';
import 'jsonViewer.dart';
class CacheView extends StatefulWidget {
static String collection = 'MarianumMobile';
const CacheView({super.key});
@override
State<CacheView> createState() => _CacheViewState();
Future<void> clear() async {
await Localstore.instance.collection(collection).delete();
await Localstore.instance.collection(RequestCache.collection).delete();
}
Future<int> totalSize() async {
var data = await Localstore.instance.collection(collection).get();
var data = await Localstore.instance.collection(RequestCache.collection).get();
if(data!.length <= 1) return jsonEncode(data.values.first).length * 8;
return data.values.reduce((a, b) => jsonEncode(a).length + jsonEncode(b).length) * 8;
}
@ -34,7 +34,7 @@ class _CacheViewState extends State<CacheView> {
@override
void initState() {
files = Localstore.instance.collection(CacheView.collection).get();
files = Localstore.instance.collection(RequestCache.collection).get();
super.initState();
}