TF-148 Add presentation layer for cleanup email cache

This commit is contained in:
dab246
2021-10-21 14:38:57 +07:00
committed by Dat H. Pham
parent 00884989d8
commit 7e8fc3a0e7
3 changed files with 31 additions and 6 deletions
@@ -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(