TF-148 Add presentation layer for cleanup email cache
This commit is contained in:
@@ -11,7 +11,7 @@ class CleanupRule with EquatableMixin {
|
||||
}
|
||||
|
||||
class Duration with EquatableMixin {
|
||||
static final defaultValue = Duration(7);
|
||||
static final defaultCacheInternal = Duration(30);
|
||||
|
||||
final int countDay;
|
||||
|
||||
|
||||
@@ -1,22 +1,34 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/data/datasource/cleanup_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/data/datasource_impl/cleanup_datasource_impl.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/data/repository/cleanup_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/repository/cleanup_repository.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_email_cache_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/home/presentation/home_controller.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/repository/credential_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_credential_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart';
|
||||
|
||||
class HomeBindings extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
|
||||
Get.lazyPut(() => GetCredentialInteractor(Get.find<CredentialRepository>()));
|
||||
|
||||
Get.lazyPut(() => CleanupDataSourceImpl(
|
||||
Get.find<EmailCacheManager>(),
|
||||
Get.find<SharedPreferences>()));
|
||||
Get.lazyPut<CleanupDataSource>(() => Get.find<CleanupDataSourceImpl>());
|
||||
Get.lazyPut(() => CleanupRepositoryImpl(Get.find<CleanupDataSource>()));
|
||||
Get.lazyPut<CleanupRepository>(() => Get.find<CleanupRepositoryImpl>());
|
||||
Get.lazyPut(() => CleanupEmailCacheInteractor(Get.find<CleanupRepository>()));
|
||||
Get.lazyPut(() => HomeController(
|
||||
Get.find<GetCredentialInteractor>(),
|
||||
Get.find<DynamicUrlInterceptors>(),
|
||||
Get.find<AuthorizationInterceptors>()));
|
||||
Get.find<AuthorizationInterceptors>(),
|
||||
Get.find<CleanupEmailCacheInteractor>()));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ import 'package:core/core.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_downloader/flutter_downloader.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/model/cleanup_rule.dart';
|
||||
import 'package:tmail_ui_user/features/cleanup/domain/usecases/cleanup_email_cache_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_credential_state.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_credential_interactor.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
@@ -11,14 +13,20 @@ class HomeController extends GetxController {
|
||||
final GetCredentialInteractor _getCredentialInteractor;
|
||||
final DynamicUrlInterceptors _dynamicUrlInterceptors;
|
||||
final AuthorizationInterceptors _authorizationInterceptors;
|
||||
final CleanupEmailCacheInteractor _cleanupEmailCacheInteractor;
|
||||
|
||||
HomeController(this._getCredentialInteractor, this._dynamicUrlInterceptors, this._authorizationInterceptors);
|
||||
HomeController(
|
||||
this._getCredentialInteractor,
|
||||
this._dynamicUrlInterceptors,
|
||||
this._authorizationInterceptors,
|
||||
this._cleanupEmailCacheInteractor,
|
||||
);
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
_initFlutterDownloader();
|
||||
_getCredentialAction();
|
||||
_cleanupEmailCache();
|
||||
}
|
||||
|
||||
void _initFlutterDownloader() {
|
||||
@@ -29,6 +37,11 @@ class HomeController extends GetxController {
|
||||
|
||||
static void downloadCallback(String id, DownloadTaskStatus status, int progress) {}
|
||||
|
||||
void _cleanupEmailCache() async {
|
||||
await _cleanupEmailCacheInteractor.execute(CleanupRule(Duration.defaultCacheInternal))
|
||||
.then((value) => _getCredentialAction());
|
||||
}
|
||||
|
||||
void _getCredentialAction() async {
|
||||
await _getCredentialInteractor.execute()
|
||||
.then((response) => response.fold(
|
||||
|
||||
Reference in New Issue
Block a user