TF-3487 Handle get mailbox failure
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -67,12 +67,9 @@ void main() {
|
||||
|
||||
final streamMailboxResponses = mailboxRepository.getAllMailbox(sessionFixture, accountIdFixture);
|
||||
|
||||
final listMailboxResponse = await streamMailboxResponses.toList();
|
||||
|
||||
expect(listMailboxResponse.length, 1);
|
||||
expect(
|
||||
listMailboxResponse,
|
||||
containsAllInOrder([
|
||||
await expectLater(
|
||||
streamMailboxResponses,
|
||||
emitsInOrder([
|
||||
CacheMailboxResponse(
|
||||
mailboxes: [
|
||||
MailboxFixtures.mailboxA,
|
||||
@@ -81,7 +78,8 @@ void main() {
|
||||
MailboxFixtures.mailboxD,
|
||||
],
|
||||
state: StateFixtures.currentMailboxState
|
||||
)
|
||||
),
|
||||
emitsError(isA<NotFoundMailboxException>())
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user