Fix forward recipients error handling
This commit is contained in:
+13
-4
@@ -1,5 +1,3 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
@@ -19,8 +17,19 @@ class AddRecipientsInForwardingInteractor {
|
||||
) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingState());
|
||||
final result = await _forwardingRepository.addRecipientsInForwarding(accountId, addRequest);
|
||||
yield Right<Failure, Success>(AddRecipientsInForwardingSuccess(result));
|
||||
final result = await _forwardingRepository.addRecipientsInForwarding(
|
||||
accountId,
|
||||
addRequest,
|
||||
);
|
||||
|
||||
if (result.$2 == null) {
|
||||
yield Right(AddRecipientsInForwardingSuccess(result.$1));
|
||||
} else {
|
||||
yield Left(AddRecipientsInForwardingSuccessWithSomeCaseFailure(
|
||||
result.$1,
|
||||
result.$2!,
|
||||
));
|
||||
}
|
||||
} catch (exception) {
|
||||
yield Left<Failure, Success>(AddRecipientsInForwardingFailure(exception));
|
||||
}
|
||||
|
||||
+11
-5
@@ -1,5 +1,3 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
@@ -20,9 +18,17 @@ class DeleteRecipientInForwardingInteractor {
|
||||
try {
|
||||
yield Right<Failure, Success>(StartDeleteRecipientInForwarding());
|
||||
final result = await _forwardingRepository.deleteRecipientInForwarding(
|
||||
accountId,
|
||||
deleteRequest);
|
||||
yield Right<Failure, Success>(DeleteRecipientInForwardingSuccess(result));
|
||||
accountId,
|
||||
deleteRequest,
|
||||
);
|
||||
if (result.$2 == null) {
|
||||
yield Right(DeleteRecipientInForwardingSuccess(result.$1));
|
||||
} else {
|
||||
yield Left(DeleteRecipientInForwardingSuccessWithSomeCaseFailure(
|
||||
result.$1,
|
||||
result.$2!,
|
||||
));
|
||||
}
|
||||
} catch (exception) {
|
||||
yield Left<Failure, Success>(DeleteRecipientInForwardingFailure(exception));
|
||||
}
|
||||
|
||||
+13
-4
@@ -1,5 +1,3 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
@@ -18,8 +16,19 @@ class EditLocalCopyInForwardingInteractor {
|
||||
EditLocalCopyInForwardingRequest editRequest,
|
||||
) async* {
|
||||
try {
|
||||
final result = await _forwardingRepository.editLocalCopyInForwarding(accountId, editRequest);
|
||||
yield Right<Failure, Success>(EditLocalCopyInForwardingSuccess(result));
|
||||
final result = await _forwardingRepository.editLocalCopyInForwarding(
|
||||
accountId,
|
||||
editRequest,
|
||||
);
|
||||
|
||||
if (result.$2 == null) {
|
||||
yield Right(EditLocalCopyInForwardingSuccess(result.$1));
|
||||
} else {
|
||||
yield Left(EditLocalCopyInForwardingSuccessWithSomeCaseFailure(
|
||||
result.$1,
|
||||
result.$2!,
|
||||
));
|
||||
}
|
||||
} catch (exception) {
|
||||
yield Left<Failure, Success>(EditLocalCopyInForwardingFailure(exception));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user