TF-1839 Clean IncomingEmailed in cache
(cherry picked from commit 005bfe41a140eb228d032d52123376b1be8473a7)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'package:core/domain/exceptions/download_file_exception.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/build_utils.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@@ -97,18 +97,16 @@ class FileUtils {
|
||||
|
||||
return File(internalStorageDirPath).exists();
|
||||
}
|
||||
}
|
||||
|
||||
enum ExtensionType {
|
||||
text,
|
||||
json;
|
||||
|
||||
String get value {
|
||||
switch(this) {
|
||||
case ExtensionType.text:
|
||||
return 'txt';
|
||||
case ExtensionType.json:
|
||||
return 'json';
|
||||
void removeFolder(String folderName) async {
|
||||
try {
|
||||
String folderPath = (await getApplicationDocumentsDirectory()).absolute.path;
|
||||
folderPath = '$folderPath/$folderName';
|
||||
log('FileUtils::removeFolder():folderPath: $folderPath');
|
||||
final dir = Directory(folderPath);
|
||||
dir.deleteSync(recursive: true);
|
||||
} catch (e) {
|
||||
logError('FileUtils::removeFolder():EXCEPTION: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/file_utils.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/account_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/detailed_email_hive_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/email_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/fcm_cache_client.dart';
|
||||
@@ -8,6 +10,7 @@ import 'package:tmail_ui_user/features/caching/clients/mailbox_cache_client.dart
|
||||
import 'package:tmail_ui_user/features/caching/clients/recent_search_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/state_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/clients/subscription_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart';
|
||||
|
||||
class CachingManager {
|
||||
@@ -19,6 +22,8 @@ class CachingManager {
|
||||
final FcmCacheClient _fcmCacheClient;
|
||||
final FCMSubscriptionCacheClient _fcmSubscriptionCacheClient;
|
||||
final HiveCacheVersionClient _hiveCacheVersionClient;
|
||||
final DetailedEmailHiveCacheClient _detailedEmailHiveCacheClient;
|
||||
final FileUtils _fileUtils;
|
||||
|
||||
CachingManager(
|
||||
this._mailboxCacheClient,
|
||||
@@ -29,6 +34,8 @@ class CachingManager {
|
||||
this._fcmCacheClient,
|
||||
this._fcmSubscriptionCacheClient,
|
||||
this._hiveCacheVersionClient,
|
||||
this._detailedEmailHiveCacheClient,
|
||||
this._fileUtils,
|
||||
);
|
||||
|
||||
Future<void> clearAll() async {
|
||||
@@ -39,8 +46,9 @@ class CachingManager {
|
||||
_fcmCacheClient.clearAllData(),
|
||||
_fcmSubscriptionCacheClient.clearAllData(),
|
||||
_recentSearchCacheClient.clearAllData(),
|
||||
_accountCacheClient.clearAllData()
|
||||
]);
|
||||
_accountCacheClient.clearAllData(),
|
||||
_detailedEmailHiveCacheClient.clearAllData(),
|
||||
], eagerError: true);
|
||||
}
|
||||
|
||||
Future<void> clearData() async {
|
||||
@@ -50,15 +58,16 @@ class CachingManager {
|
||||
_emailCacheClient.clearAllData(),
|
||||
_fcmCacheClient.clearAllData(),
|
||||
_fcmSubscriptionCacheClient.clearAllData(),
|
||||
_recentSearchCacheClient.clearAllData()
|
||||
]);
|
||||
_recentSearchCacheClient.clearAllData(),
|
||||
_detailedEmailHiveCacheClient.clearAllData(),
|
||||
], eagerError: true);
|
||||
}
|
||||
|
||||
Future<void> clearEmailCache() async {
|
||||
await Future.wait([
|
||||
_stateCacheClient.deleteItem(StateType.email.value),
|
||||
_emailCacheClient.clearAllData(),
|
||||
]);
|
||||
], eagerError: true);
|
||||
log('CachingManager::clearEmailCache(): success');
|
||||
}
|
||||
|
||||
@@ -81,4 +90,8 @@ class CachingManager {
|
||||
Future<void> closeHive() async {
|
||||
return await HiveCacheConfig().closeHive();
|
||||
}
|
||||
|
||||
void clearAllFileInStorage() {
|
||||
_fileUtils.removeFolder(CachingConstants.incomingEmailedContentFolderName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,12 @@ class CachingConstants {
|
||||
|
||||
static const String fcmCacheBoxName = 'fcm_cache_box';
|
||||
static const String incomingEmailedCacheBoxName = 'incoming_emailed_cache_box';
|
||||
static const String incomingEmailedContentFolderName = 'incoming_emailed';
|
||||
static const String openedEmailContentFolderName = 'opened_email';
|
||||
static const String openedEmailCacheBoxName = 'opened_email_cache_box';
|
||||
static const String sendingEmailCacheBoxName = 'sending_email_cache_box';
|
||||
|
||||
static const String incomingEmailedContentFolderName = 'incoming_emailed';
|
||||
static const String openedEmailContentFolderName = 'opened_email';
|
||||
|
||||
static const int maxNumberNewEmailsForOffline = 10;
|
||||
static const int maxNumberOpenedEmailsForOffline = 30;
|
||||
}
|
||||
@@ -88,7 +88,9 @@ class LocalBindings extends Bindings {
|
||||
Get.find<AccountCacheClient>(),
|
||||
Get.find<FcmCacheClient>(),
|
||||
Get.find<FCMSubscriptionCacheClient>(),
|
||||
Get.find<HiveCacheVersionClient>()
|
||||
Get.find<HiveCacheVersionClient>(),
|
||||
Get.find<DetailedEmailHiveCacheClient>(),
|
||||
Get.find<FileUtils>(),
|
||||
));
|
||||
Get.put(SharePreferenceSpamReportDataSource(Get.find<SharedPreferences>()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user