TF-2564 Change logic empty folder (Spam/Trash) to avoid cache still has data

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2024-02-07 01:24:15 +07:00
committed by Dat PHAM HOANG
parent 1c7ecc0a50
commit 1bf7ee4f20
6 changed files with 44 additions and 59 deletions
@@ -65,21 +65,21 @@ class EmailCacheManager {
List<Email>? created,
List<EmailId>? destroyed
}) async {
final emailCacheExist = await _emailCacheClient.isExistTable();
if (emailCacheExist) {
final updatedCacheEmails = updated?.toMapCache(accountId, userName) ?? {};
final createdCacheEmails = created?.toMapCache(accountId, userName) ?? {};
final destroyedCacheEmails = destroyed?.toCacheKeyList(accountId, userName) ?? [];
await Future.wait([
_emailCacheClient.updateMultipleItem(updatedCacheEmails),
_emailCacheClient.insertMultipleItem(createdCacheEmails),
_emailCacheClient.deleteMultipleItem(destroyedCacheEmails)
]);
} else {
final createdCacheEmails = created?.toMapCache(accountId, userName) ?? {};
if (created?.isNotEmpty == true) {
final createdCacheEmails = created!.toMapCache(accountId, userName);
await _emailCacheClient.insertMultipleItem(createdCacheEmails);
}
if (updated?.isNotEmpty == true) {
final updatedCacheEmails = updated!.toMapCache(accountId, userName);
await _emailCacheClient.updateMultipleItem(updatedCacheEmails);
}
final emailCacheExist = await _emailCacheClient.isExistTable();
if (destroyed?.isNotEmpty == true && emailCacheExist) {
final destroyedCacheEmails = destroyed!.toCacheKeyList(accountId, userName);
await _emailCacheClient.deleteMultipleItem(destroyedCacheEmails);
}
}
Future<void> clean(EmailCleanupRule cleanupRule) async {