refactoring
security update
This commit is contained in:
parent
1747ab0245
commit
78fe9e7b09
39 changed files with 289 additions and 132 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||
import 'dart:collection';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:mc_gallery/features/home/data/dtos/image_model_dto.dart';
|
||||
|
||||
import '/features/core/data/constants/const_sorters.dart';
|
||||
import '/features/core/data/extensions/iterable_extensions.dart';
|
||||
|
@ -11,6 +10,7 @@ import '/features/core/data/extensions/string_extensions.dart';
|
|||
import '/features/core/services/local_storage_service.dart';
|
||||
import '/features/core/services/logging_service.dart';
|
||||
import '/features/core/utils/mutex.dart';
|
||||
import '/features/home/data/dtos/image_model_dto.dart';
|
||||
import '/locator.dart';
|
||||
import '../abstracts/images_api.dart';
|
||||
import '../data/enums/search_option.dart';
|
||||
|
@ -49,7 +49,7 @@ class ImagesService {
|
|||
Future<void> _init() async {
|
||||
_loggingService.info('Fetching and creating image models...');
|
||||
|
||||
final fetchedImageModelDtos = await _imagesApi.fetchImageUri(token: '');
|
||||
final fetchedImageModelDtos = await _imagesApi.fetchImageUri();
|
||||
final favouritesStatuses = _localStorageService.storedFavouritesStates;
|
||||
|
||||
// Prefill from stored values
|
||||
|
@ -128,7 +128,6 @@ class ImagesService {
|
|||
case SearchOption.web:
|
||||
return (await _imagesApi.searchImages(
|
||||
searchStr: imageNamePart,
|
||||
token: '',
|
||||
))
|
||||
.map(
|
||||
(final imageModelDto) => ImageModel.fromDto(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue