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