TF-561 Fix edit identity

This commit is contained in:
dab246
2022-05-16 18:46:27 +07:00
committed by Dat H. Pham
parent 29a5649a84
commit 0d40f765e6
18 changed files with 333 additions and 117 deletions
@@ -12,10 +12,13 @@ class EditIdentityInteractor {
EditIdentityInteractor(this.manageAccountRepository);
Stream<Either<Failure, Success>> execute(AccountId accountId, EditIdentityRequest identityRequest) async* {
Stream<Either<Failure, Success>> execute(
AccountId accountId,
EditIdentityRequest editIdentityRequest
) async* {
try {
final newIdentity = await manageAccountRepository.editIdentity(accountId, identityRequest);
yield Right(EditIdentitySuccess(newIdentity));
final result = await manageAccountRepository.editIdentity(accountId, editIdentityRequest);
yield result ? Right(EditIdentitySuccess()) : Left(EditIdentityFailure(null));
} catch (exception) {
yield Left(EditIdentityFailure(exception));
}
@@ -3,6 +3,7 @@ import 'dart:core';
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/properties/properties.dart';
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
import 'package:tmail_ui_user/features/manage_account/domain/state/get_all_identities_state.dart';
@@ -11,10 +12,10 @@ class GetAllIdentitiesInteractor {
GetAllIdentitiesInteractor(this.manageAccountRepository);
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
Stream<Either<Failure, Success>> execute(AccountId accountId, {Properties? properties}) async* {
try {
yield Right<Failure, Success>(LoadingState());
final identitiesResponse = await manageAccountRepository.getAllIdentities(accountId);
final identitiesResponse = await manageAccountRepository.getAllIdentities(accountId, properties: properties);
yield Right(GetAllIdentitiesSuccess(identitiesResponse.identities, identitiesResponse.state));
} catch (exception) {
yield Left(GetAllIdentitiesFailure(exception));