TF-561 Fix edit identity
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class EditIdentityRequest with EquatableMixin {
|
||||
|
||||
final Identity newIdentity;
|
||||
final IdentityRequestDto identityRequest;
|
||||
final IdentityId identityId;
|
||||
|
||||
EditIdentityRequest(this.identityId, this.newIdentity);
|
||||
EditIdentityRequest({required this.identityId, required this.identityRequest});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [identityId, newIdentity];
|
||||
List<Object?> get props => [identityId, identityRequest];
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/create_new_identity_request.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/edit_identity_request.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/identities_response.dart';
|
||||
|
||||
abstract class ManageAccountRepository {
|
||||
Future<IdentitiesResponse> getAllIdentities(AccountId accountId);
|
||||
Future<IdentitiesResponse> getAllIdentities(AccountId accountId, {Properties? properties});
|
||||
|
||||
Future<Identity> createNewIdentity(AccountId accountId, CreateNewIdentityRequest identityRequest);
|
||||
|
||||
Future<bool> deleteIdentity(AccountId accountId, IdentityId identityId);
|
||||
|
||||
Future<Identity> editIdentity(AccountId accountId, EditIdentityRequest identityRequest);
|
||||
Future<bool> editIdentity(AccountId accountId, EditIdentityRequest editIdentityRequest);
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
|
||||
class EditIdentitySuccess extends UIState {
|
||||
|
||||
final Identity newIdentity;
|
||||
|
||||
EditIdentitySuccess(this.newIdentity);
|
||||
EditIdentitySuccess();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [newIdentity];
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class EditIdentityFailure extends FeatureFailure {
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user