improved performance and battery usage on older devices
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user