TF-1311 Add capability of Team-Mailbox for GetMailboxMethod
This commit is contained in:
@@ -158,14 +158,14 @@ class DestinationPickerController extends BaseMailboxController {
|
||||
}
|
||||
|
||||
void getAllMailboxAction() {
|
||||
if (accountId != null) {
|
||||
if (accountId != null && _session != null) {
|
||||
consumeState(_getAllMailboxInteractor.execute(_session!, accountId!));
|
||||
}
|
||||
}
|
||||
|
||||
void _refreshMailboxChanges(jmap.State currentMailboxState) {
|
||||
if (accountId != null) {
|
||||
consumeState(_refreshAllMailboxInteractor.execute(accountId!, currentMailboxState));
|
||||
if (accountId != null && _session != null) {
|
||||
consumeState(_refreshAllMailboxInteractor.execute(_session!, accountId!, currentMailboxState));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ abstract class MailboxDataSource {
|
||||
|
||||
Future<List<Mailbox>> getAllMailboxCache();
|
||||
|
||||
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState);
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState);
|
||||
|
||||
Future<void> update({List<Mailbox>? updated, List<Mailbox>? created, List<MailboxId>? destroyed});
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MailboxCacheDataSourceImpl extends MailboxDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState) {
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,9 +40,9 @@ class MailboxDataSourceImpl extends MailboxDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState) {
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) {
|
||||
return Future.sync(() async {
|
||||
return await mailboxAPI.getChanges(accountId, sinceState);
|
||||
return await mailboxAPI.getChanges(session, accountId, sinceState);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
|
||||
final queryInvocation = jmapRequestBuilder.invocation(getMailboxCreated);
|
||||
|
||||
final capabilities = capabilitiesSupportedMailboxes(session, accountId);
|
||||
final capabilities = capabilitiesForGetMailboxMethod(session, accountId);
|
||||
|
||||
final result = await (jmapRequestBuilder
|
||||
..usings(capabilities))
|
||||
@@ -63,7 +63,7 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
return MailboxResponse(mailboxes: resultCreated?.list, state: resultCreated?.state);
|
||||
}
|
||||
|
||||
Set<CapabilityIdentifier> capabilitiesSupportedMailboxes(Session session, AccountId accountId) {
|
||||
Set<CapabilityIdentifier> capabilitiesForGetMailboxMethod(Session session, AccountId accountId) {
|
||||
final getMailboxCreated = GetMailboxMethod(accountId);
|
||||
try {
|
||||
requireCapability(
|
||||
@@ -76,7 +76,7 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
}
|
||||
}
|
||||
|
||||
Future<MailboxChangeResponse> getChanges(AccountId accountId, State sinceState) async {
|
||||
Future<MailboxChangeResponse> getChanges(Session session, AccountId accountId, State sinceState) async {
|
||||
final processingInvocation = ProcessingInvocation();
|
||||
|
||||
final jmapRequestBuilder = JmapRequestBuilder(httpClient, processingInvocation);
|
||||
@@ -101,8 +101,10 @@ class MailboxAPI with HandleSetErrorMixin {
|
||||
final getMailboxUpdatedInvocation = jmapRequestBuilder.invocation(getMailboxUpdated);
|
||||
final getMailboxCreatedInvocation = jmapRequestBuilder.invocation(getMailboxCreated);
|
||||
|
||||
final capabilities = capabilitiesForGetMailboxMethod(session, accountId);
|
||||
|
||||
final result = await (jmapRequestBuilder
|
||||
..usings(getMailboxCreated.requiredCapabilities))
|
||||
..usings(capabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class MailboxRepositoryImpl extends MailboxRepository {
|
||||
State? sinceState = localMailboxResponse.state!;
|
||||
|
||||
while(hasMoreChanges && sinceState != null) {
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(accountId, sinceState);
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState);
|
||||
|
||||
hasMoreChanges = changesResponse.hasMoreChanges;
|
||||
sinceState = changesResponse.newStateChanges;
|
||||
@@ -115,14 +115,14 @@ class MailboxRepositoryImpl extends MailboxRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<MailboxResponse> refresh(AccountId accountId, State currentState) async* {
|
||||
Stream<MailboxResponse> refresh(Session session, AccountId accountId, State currentState) async* {
|
||||
final localMailboxList = await mapDataSource[DataSourceType.local]!.getAllMailboxCache();
|
||||
|
||||
bool hasMoreChanges = true;
|
||||
State? sinceState = currentState;
|
||||
|
||||
while(hasMoreChanges && sinceState != null) {
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(accountId, sinceState);
|
||||
final changesResponse = await mapDataSource[DataSourceType.network]!.getChanges(session, accountId, sinceState);
|
||||
|
||||
hasMoreChanges = changesResponse.hasMoreChanges;
|
||||
sinceState = changesResponse.newStateChanges;
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'package:tmail_ui_user/features/mailbox/domain/model/subscribe_mailbox_re
|
||||
abstract class MailboxRepository {
|
||||
Stream<MailboxResponse> getAllMailbox(Session session, AccountId accountId, {Properties? properties});
|
||||
|
||||
Stream<MailboxResponse> refresh(AccountId accountId, State currentState);
|
||||
Stream<MailboxResponse> refresh(Session session, AccountId accountId, State currentState);
|
||||
|
||||
Future<Mailbox?> createNewMailbox(AccountId accountId, CreateNewMailboxRequest newMailboxRequest);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmapState;
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/domain/model/mailbox_response.dart';
|
||||
@@ -12,12 +13,12 @@ class RefreshAllMailboxInteractor {
|
||||
|
||||
RefreshAllMailboxInteractor(this._mailboxRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, jmapState.State currentState) async* {
|
||||
Stream<Either<Failure, Success>> execute(Session session, AccountId accountId, jmapState.State currentState) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(RefreshingState());
|
||||
|
||||
yield* _mailboxRepository
|
||||
.refresh(accountId, currentState)
|
||||
.refresh(session, accountId, currentState)
|
||||
.map(_toGetMailboxState);
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(RefreshChangesAllMailboxFailure(e));
|
||||
|
||||
@@ -330,8 +330,9 @@ class MailboxController extends BaseMailboxController {
|
||||
final newMailboxState = currentMailboxState ?? _currentMailboxState;
|
||||
log('MailboxController::refreshMailboxChanges(): newMailboxState: $newMailboxState');
|
||||
final accountId = mailboxDashBoardController.accountId.value;
|
||||
if (accountId != null && newMailboxState != null) {
|
||||
consumeState(_refreshAllMailboxInteractor.execute(accountId, newMailboxState));
|
||||
final session = mailboxDashBoardController.sessionCurrent;
|
||||
if (accountId != null && session != null && newMailboxState != null) {
|
||||
consumeState(_refreshAllMailboxInteractor.execute(session, accountId, newMailboxState));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user