TF-3487 Handle get mailbox failure

This commit is contained in:
DatDang
2025-02-24 10:38:51 +07:00
committed by Dat H. Pham
parent 33b90d3c65
commit f23b9eed71
5 changed files with 17 additions and 20 deletions
@@ -87,17 +87,12 @@ class MailboxRepositoryImpl extends MailboxRepository {
Session session,
{Properties? properties}
) async {
try {
final jmapMailboxResponse = await mapDataSource[DataSourceType.network]!.getAllMailbox(
session,
accountId,
properties: properties);
log('MailboxRepositoryImpl::_getAllMailboxFromJMAP: MAILBOX_NETWORK = ${jmapMailboxResponse.mailboxes.length} | STATE_NETWORK = ${jmapMailboxResponse.state}');
return jmapMailboxResponse;
} catch (e) {
logError('MailboxRepositoryImpl::_getAllMailboxFromJMAP: Exception: $e');
return null;
}
final jmapMailboxResponse = await mapDataSource[DataSourceType.network]!.getAllMailbox(
session,
accountId,
properties: properties);
log('MailboxRepositoryImpl::_getAllMailboxFromJMAP: MAILBOX_NETWORK = ${jmapMailboxResponse.mailboxes.length} | STATE_NETWORK = ${jmapMailboxResponse.state}');
return jmapMailboxResponse;
}
Future<void> _syncNewInCache(
@@ -19,5 +19,5 @@ class GetAllMailboxSuccess extends UIState {
class GetAllMailboxFailure extends FeatureFailure {
GetAllMailboxFailure(dynamic exception) : super(exception: exception);
GetAllMailboxFailure(dynamic exception, {super.onRetry}) : super(exception: exception);
}
@@ -25,7 +25,10 @@ class GetAllMailboxInteractor {
properties: properties)
.map(_toGetMailboxState);
} catch (e) {
yield Left<Failure, Success>(GetAllMailboxFailure(e));
yield Left<Failure, Success>(GetAllMailboxFailure(
e,
onRetry: execute(session, accountId, properties: properties),
));
}
}
@@ -232,6 +232,7 @@ class MailboxController extends BaseMailboxController
(failure) {
if (failure is GetAllMailboxFailure) {
mailboxDashBoardController.updateRefreshAllMailboxState(Left(RefreshAllMailboxFailure()));
showRetryToast(failure);
}
},
(success) {