improved performance and battery usage on older devices

This commit is contained in:
2026-09-25 23:58:08 +02:00
parent ed8e52f475
commit 56a497985b
70 changed files with 1631 additions and 621 deletions
+3 -19
View File
@@ -1,24 +1,8 @@
import 'package:localstore/localstore.dart';
import '../api/request_cache.dart';
import '../api/cache_store.dart';
class DataCleaner {
static Future<void> cleanOldCache() async {
final cacheData = await Localstore.instance
.collection(RequestCache.collection)
.get();
cacheData?.forEach((key, value) async {
final lastUpdate = DateTime.fromMillisecondsSinceEpoch(
((value['lastupdate'] as num?) ?? 0).toInt(),
);
if (DateTime.now()
.subtract(const Duration(days: 200))
.isAfter(lastUpdate)) {
await Localstore.instance
.collection(RequestCache.collection)
.doc(key.split('/').last)
.delete();
}
});
await CacheStore.deleteLegacyLocalstoreCache();
await CacheStore.instance.deleteOlderThan(const Duration(days: 200));
}
}