diff --git a/lib/features/mailbox/data/repository/mailbox_repository_impl.dart b/lib/features/mailbox/data/repository/mailbox_repository_impl.dart index f00f13a5b..b4e8e3273 100644 --- a/lib/features/mailbox/data/repository/mailbox_repository_impl.dart +++ b/lib/features/mailbox/data/repository/mailbox_repository_impl.dart @@ -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 _syncNewInCache( diff --git a/lib/features/mailbox/domain/state/get_all_mailboxes_state.dart b/lib/features/mailbox/domain/state/get_all_mailboxes_state.dart index 3cb2486a6..6490e923a 100644 --- a/lib/features/mailbox/domain/state/get_all_mailboxes_state.dart +++ b/lib/features/mailbox/domain/state/get_all_mailboxes_state.dart @@ -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); } \ No newline at end of file diff --git a/lib/features/mailbox/domain/usecases/get_all_mailbox_interactor.dart b/lib/features/mailbox/domain/usecases/get_all_mailbox_interactor.dart index 367848876..07d6be5c6 100644 --- a/lib/features/mailbox/domain/usecases/get_all_mailbox_interactor.dart +++ b/lib/features/mailbox/domain/usecases/get_all_mailbox_interactor.dart @@ -25,7 +25,10 @@ class GetAllMailboxInteractor { properties: properties) .map(_toGetMailboxState); } catch (e) { - yield Left(GetAllMailboxFailure(e)); + yield Left(GetAllMailboxFailure( + e, + onRetry: execute(session, accountId, properties: properties), + )); } } diff --git a/lib/features/mailbox/presentation/mailbox_controller.dart b/lib/features/mailbox/presentation/mailbox_controller.dart index 4373582e9..b0fb7ff0c 100644 --- a/lib/features/mailbox/presentation/mailbox_controller.dart +++ b/lib/features/mailbox/presentation/mailbox_controller.dart @@ -232,6 +232,7 @@ class MailboxController extends BaseMailboxController (failure) { if (failure is GetAllMailboxFailure) { mailboxDashBoardController.updateRefreshAllMailboxState(Left(RefreshAllMailboxFailure())); + showRetryToast(failure); } }, (success) { diff --git a/test/features/mailbox/repository/mailbox_respository_test.dart b/test/features/mailbox/repository/mailbox_respository_test.dart index d204fd614..38528da04 100644 --- a/test/features/mailbox/repository/mailbox_respository_test.dart +++ b/test/features/mailbox/repository/mailbox_respository_test.dart @@ -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()) ]) ); });