refactoring

security update
This commit is contained in:
Mguy13 2022-12-25 22:17:59 +01:00
parent 1747ab0245
commit 78fe9e7b09
39 changed files with 289 additions and 132 deletions

View file

@ -1,12 +1,14 @@
import 'dart:ui';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:mc_gallery/features/core/services/app_lifecycle_service.dart';
import 'package:mc_gallery/features/core/services/local_storage_service.dart';
import 'package:mc_gallery/features/core/services/logging_service.dart';
import 'package:mc_gallery/locator.dart';
class ImageCacheManagerService with LoggingService {
import '/features/core/services/app_lifecycle_service.dart';
import '/features/core/services/local_storage_service.dart';
import '/features/core/services/logging_service.dart';
import '/locator.dart';
/// Handles maintaining the caching of downloaded images
class ImageCacheManagerService {
ImageCacheManagerService(
{required AppLifecycleService appLifecycleService,
required LocalStorageService localStorageService})
@ -17,6 +19,7 @@ class ImageCacheManagerService with LoggingService {
final AppLifecycleService _appLifecycleService;
final LocalStorageService _localStorageService;
final LoggingService _loggingService = LoggingService.locate;
final _cacheManager = DefaultCacheManager();
Future<void> emptyCache() async => await _cacheManager.emptyCache();
@ -31,7 +34,7 @@ class ImageCacheManagerService with LoggingService {
case AppLifecycleState.inactive:
case AppLifecycleState.paused:
case AppLifecycleState.detached:
info('Discarding cached images');
_loggingService.info('Discarding cached images');
await _cacheManager.emptyCache();
_localStorageService.resetFavourites();
}