TF-3385 Add try-catch to cache method calls on user actions
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:core/data/network/download/downloaded_response.dart';
|
|||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
|
import 'package:core/presentation/utils/html_transformer/transform_configuration.dart';
|
||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:email_recovery/email_recovery/email_recovery_action.dart';
|
import 'package:email_recovery/email_recovery/email_recovery_action.dart';
|
||||||
@@ -101,12 +102,16 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
readActions,
|
readActions,
|
||||||
);
|
);
|
||||||
|
|
||||||
await emailDataSource[DataSourceType.hiveCache]!.markAsRead(
|
try {
|
||||||
session,
|
await emailDataSource[DataSourceType.hiveCache]!.markAsRead(
|
||||||
accountId,
|
session,
|
||||||
result.emailIdsSuccess,
|
accountId,
|
||||||
readActions,
|
result.emailIdsSuccess,
|
||||||
);
|
readActions,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::markAsRead:exception $e');
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -159,18 +164,22 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await emailDataSource[DataSourceType.hiveCache]
|
try {
|
||||||
!.moveToMailbox(
|
await emailDataSource[DataSourceType.hiveCache]
|
||||||
session,
|
!.moveToMailbox(
|
||||||
accountId,
|
session,
|
||||||
MoveToMailboxRequest(
|
accountId,
|
||||||
updatedCurrentMailboxes,
|
MoveToMailboxRequest(
|
||||||
moveRequest.destinationMailboxId,
|
updatedCurrentMailboxes,
|
||||||
moveRequest.moveAction,
|
moveRequest.destinationMailboxId,
|
||||||
moveRequest.emailActionType,
|
moveRequest.moveAction,
|
||||||
destinationPath: moveRequest.destinationPath,
|
moveRequest.emailActionType,
|
||||||
),
|
destinationPath: moveRequest.destinationPath,
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::moveToMailbox:exception $e');
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -191,12 +200,16 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
emailIds,
|
emailIds,
|
||||||
markStarAction,
|
markStarAction,
|
||||||
);
|
);
|
||||||
await emailDataSource[DataSourceType.hiveCache]!.markAsStar(
|
try {
|
||||||
session,
|
await emailDataSource[DataSourceType.hiveCache]!.markAsStar(
|
||||||
accountId,
|
session,
|
||||||
result.emailIdsSuccess,
|
accountId,
|
||||||
markStarAction
|
result.emailIdsSuccess,
|
||||||
);
|
markStarAction
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::markAsStar:exception $e');
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,12 +243,16 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
email,
|
email,
|
||||||
cancelToken: cancelToken
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
await emailDataSource[DataSourceType.hiveCache]!.saveEmailAsDrafts(
|
try {
|
||||||
session,
|
await emailDataSource[DataSourceType.hiveCache]!.saveEmailAsDrafts(
|
||||||
accountId,
|
session,
|
||||||
result,
|
accountId,
|
||||||
cancelToken: cancelToken
|
result,
|
||||||
);
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::saveEmailAsDrafts:exception $e');
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,12 +269,16 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
emailId,
|
emailId,
|
||||||
cancelToken: cancelToken
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
await emailDataSource[DataSourceType.hiveCache]!.removeEmailDrafts(
|
try {
|
||||||
session,
|
await emailDataSource[DataSourceType.hiveCache]!.removeEmailDrafts(
|
||||||
accountId,
|
session,
|
||||||
emailId,
|
accountId,
|
||||||
cancelToken: cancelToken
|
emailId,
|
||||||
);
|
cancelToken: cancelToken
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::removeEmailDrafts:exception $e');
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,12 +297,16 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
oldEmailId,
|
oldEmailId,
|
||||||
cancelToken: cancelToken
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
await emailDataSource[DataSourceType.hiveCache]!.updateEmailDrafts(
|
try {
|
||||||
session,
|
await emailDataSource[DataSourceType.hiveCache]!.updateEmailDrafts(
|
||||||
accountId,
|
session,
|
||||||
result,
|
accountId,
|
||||||
oldEmailId,
|
result,
|
||||||
);
|
oldEmailId,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::updateEmailDrafts:exception $e');
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,8 +345,12 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
accountId,
|
accountId,
|
||||||
emailIds,
|
emailIds,
|
||||||
);
|
);
|
||||||
await emailDataSource[DataSourceType.hiveCache]
|
try {
|
||||||
!.deleteMultipleEmailsPermanently(session, accountId, result.emailIdsSuccess);
|
await emailDataSource[DataSourceType.hiveCache]
|
||||||
|
!.deleteMultipleEmailsPermanently(session, accountId, result.emailIdsSuccess);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::deleteMultipleEmailsPermanently:exception $e');
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -339,11 +368,15 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
emailId,
|
emailId,
|
||||||
cancelToken: cancelToken
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
await emailDataSource[DataSourceType.hiveCache]!.deleteEmailPermanently(
|
try {
|
||||||
session,
|
await emailDataSource[DataSourceType.hiveCache]!.deleteEmailPermanently(
|
||||||
accountId,
|
session,
|
||||||
emailId,
|
accountId,
|
||||||
);
|
emailId,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('EmailRepositoryImpl::deleteEmailPermanently:exception $e');
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,8 +219,12 @@ class MailboxRepositoryImpl extends MailboxRepository {
|
|||||||
final result = await mapDataSource[DataSourceType.network]
|
final result = await mapDataSource[DataSourceType.network]
|
||||||
!.renameMailbox(session, accountId, request);
|
!.renameMailbox(session, accountId, request);
|
||||||
|
|
||||||
await mapDataSource[DataSourceType.local]
|
try {
|
||||||
!.renameMailbox(session, accountId, request);
|
await mapDataSource[DataSourceType.local]
|
||||||
|
!.renameMailbox(session, accountId, request);
|
||||||
|
} catch (e) {
|
||||||
|
logError('MailboxRepositoryImpl::renameMailbox: Exception: $e');
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -239,19 +243,23 @@ class MailboxRepositoryImpl extends MailboxRepository {
|
|||||||
mailboxId,
|
mailboxId,
|
||||||
totalEmailUnread,
|
totalEmailUnread,
|
||||||
onProgressController);
|
onProgressController);
|
||||||
await mapDataSource[DataSourceType.local]!.markAsMailboxRead(
|
try {
|
||||||
session,
|
await mapDataSource[DataSourceType.local]!.markAsMailboxRead(
|
||||||
accountId,
|
session,
|
||||||
mailboxId,
|
accountId,
|
||||||
totalEmailUnread - result.length,
|
mailboxId,
|
||||||
onProgressController,
|
totalEmailUnread - result.length,
|
||||||
);
|
onProgressController,
|
||||||
await emailDataSource?.markAsRead(
|
);
|
||||||
session,
|
await emailDataSource?.markAsRead(
|
||||||
accountId,
|
session,
|
||||||
result,
|
accountId,
|
||||||
ReadActions.markAsRead,
|
result,
|
||||||
);
|
ReadActions.markAsRead,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
logError('MailboxRepositoryImpl::markAsMailboxRead: Exception: $e');
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user