TF-3043 Dereference public assets before delete identity
This commit is contained in:
+21
-3
@@ -1,14 +1,32 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
|
||||
class RemovingIdentityFromPublicAssetsState extends LoadingState {}
|
||||
|
||||
class RemoveIdentityFromPublicAssetsSuccessState extends UIState {}
|
||||
class RemoveIdentityFromPublicAssetsSuccessState extends UIState {
|
||||
RemoveIdentityFromPublicAssetsSuccessState({required this.identityId});
|
||||
|
||||
final IdentityId identityId;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [identityId];
|
||||
}
|
||||
|
||||
class RemoveIdentityFromPublicAssetsFailureState extends FeatureFailure {
|
||||
RemoveIdentityFromPublicAssetsFailureState({super.exception});
|
||||
RemoveIdentityFromPublicAssetsFailureState({super.exception, required this.identityId});
|
||||
|
||||
final IdentityId identityId;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [...super.props, identityId];
|
||||
}
|
||||
|
||||
class NotFoundAnyPublicAssetsFailureState extends FeatureFailure {
|
||||
NotFoundAnyPublicAssetsFailureState({super.exception});
|
||||
NotFoundAnyPublicAssetsFailureState({super.exception, required this.identityId});
|
||||
|
||||
final IdentityId identityId;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [...super.props, identityId];
|
||||
}
|
||||
+1
-1
@@ -31,7 +31,7 @@ class AddIdentityToPublicAssetsInteractor {
|
||||
publicAssetIds: publicAssetIds
|
||||
);
|
||||
if (publicAssets.isEmpty) {
|
||||
yield Left(NotFoundAnyPublicAssetsFailureState());
|
||||
yield Left(NotFoundAnyPublicAssetsFailureState(identityId: identityId));
|
||||
} else {
|
||||
final publicAssetsWithCurrentIdentity = publicAssets
|
||||
.map((publicAsset) => publicAsset.withAddedIdentityId(identityId))
|
||||
|
||||
+5
-3
@@ -30,7 +30,7 @@ class RemoveIdentityFromPublicAssetsInteractor {
|
||||
publicAssetIds: publicAssetIds
|
||||
);
|
||||
if (publicAssets.isEmpty) {
|
||||
yield Left(NotFoundAnyPublicAssetsFailureState());
|
||||
yield Left(NotFoundAnyPublicAssetsFailureState(identityId: identityId));
|
||||
} else {
|
||||
final publicAssetsWithCurrentIdentity = publicAssets
|
||||
.map((publicAsset) => publicAsset.withRemovedIdentityId(identityId))
|
||||
@@ -40,10 +40,12 @@ class RemoveIdentityFromPublicAssetsInteractor {
|
||||
accountId,
|
||||
publicAssets: publicAssetsWithCurrentIdentity
|
||||
);
|
||||
yield Right(RemoveIdentityFromPublicAssetsSuccessState());
|
||||
yield Right(RemoveIdentityFromPublicAssetsSuccessState(identityId: identityId));
|
||||
}
|
||||
} catch (exception) {
|
||||
yield Left(RemoveIdentityFromPublicAssetsFailureState(exception: exception));
|
||||
yield Left(RemoveIdentityFromPublicAssetsFailureState(
|
||||
exception: exception,
|
||||
identityId: identityId));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user