Fix forward recipients error handling
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:forward/forward/tmail_forward.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/add_recipients_in_forwarding_request.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/delete_recipient_in_forwarding_request.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/edit_local_copy_in_forwarding_request.dart';
|
||||
@@ -7,9 +8,18 @@ import 'package:tmail_ui_user/features/manage_account/domain/model/edit_local_co
|
||||
abstract class ForwardingRepository {
|
||||
Future<TMailForward> getForward(AccountId accountId);
|
||||
|
||||
Future<TMailForward> deleteRecipientInForwarding(AccountId accountId, DeleteRecipientInForwardingRequest deleteRequest);
|
||||
Future<(TMailForward, SetMethodException?)> deleteRecipientInForwarding(
|
||||
AccountId accountId,
|
||||
DeleteRecipientInForwardingRequest deleteRequest,
|
||||
);
|
||||
|
||||
Future<TMailForward> addRecipientsInForwarding(AccountId accountId, AddRecipientInForwardingRequest addRequest);
|
||||
Future<(TMailForward, SetMethodException?)> addRecipientsInForwarding(
|
||||
AccountId accountId,
|
||||
AddRecipientInForwardingRequest addRequest,
|
||||
);
|
||||
|
||||
Future<TMailForward> editLocalCopyInForwarding(AccountId accountId, EditLocalCopyInForwardingRequest editRequest);
|
||||
Future<(TMailForward, SetMethodException?)> editLocalCopyInForwarding(
|
||||
AccountId accountId,
|
||||
EditLocalCopyInForwardingRequest editRequest,
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:forward/forward/tmail_forward.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/update_forwarding_state.dart';
|
||||
|
||||
class AddRecipientsInForwardingSuccess extends UIState {
|
||||
final TMailForward forward;
|
||||
@@ -11,6 +12,14 @@ class AddRecipientsInForwardingSuccess extends UIState {
|
||||
List<Object?> get props => [forward];
|
||||
}
|
||||
|
||||
class AddRecipientsInForwardingSuccessWithSomeCaseFailure
|
||||
extends UpdateForwardingCompleteWithSomeCaseFailure {
|
||||
AddRecipientsInForwardingSuccessWithSomeCaseFailure(
|
||||
super.forward,
|
||||
super.exception,
|
||||
);
|
||||
}
|
||||
|
||||
class AddRecipientsInForwardingFailure extends FeatureFailure {
|
||||
|
||||
AddRecipientsInForwardingFailure(dynamic exception) : super(exception: exception);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:forward/forward/tmail_forward.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/update_forwarding_state.dart';
|
||||
|
||||
class StartDeleteRecipientInForwarding extends UIState {}
|
||||
|
||||
@@ -13,6 +14,14 @@ class DeleteRecipientInForwardingSuccess extends UIState {
|
||||
List<Object?> get props => [forward];
|
||||
}
|
||||
|
||||
class DeleteRecipientInForwardingSuccessWithSomeCaseFailure
|
||||
extends UpdateForwardingCompleteWithSomeCaseFailure {
|
||||
DeleteRecipientInForwardingSuccessWithSomeCaseFailure(
|
||||
super.forward,
|
||||
super.exception,
|
||||
);
|
||||
}
|
||||
|
||||
class DeleteRecipientInForwardingFailure extends FeatureFailure {
|
||||
|
||||
DeleteRecipientInForwardingFailure(dynamic exception) : super(exception: exception);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:forward/forward/tmail_forward.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/update_forwarding_state.dart';
|
||||
|
||||
class EditLocalCopyInForwardingSuccess extends UIState {
|
||||
final TMailForward forward;
|
||||
@@ -11,6 +12,14 @@ class EditLocalCopyInForwardingSuccess extends UIState {
|
||||
List<Object?> get props => [forward];
|
||||
}
|
||||
|
||||
class EditLocalCopyInForwardingSuccessWithSomeCaseFailure
|
||||
extends UpdateForwardingCompleteWithSomeCaseFailure {
|
||||
EditLocalCopyInForwardingSuccessWithSomeCaseFailure(
|
||||
super.forward,
|
||||
super.exception,
|
||||
);
|
||||
}
|
||||
|
||||
class EditLocalCopyInForwardingFailure extends FeatureFailure {
|
||||
|
||||
EditLocalCopyInForwardingFailure(dynamic exception) : super(exception: exception);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:forward/forward/tmail_forward.dart';
|
||||
|
||||
class UpdateForwardingCompleteWithSomeCaseFailure extends FeatureFailure {
|
||||
final TMailForward forward;
|
||||
|
||||
UpdateForwardingCompleteWithSomeCaseFailure(this.forward, dynamic exception)
|
||||
: super(exception: exception);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [forward, ...super.props];
|
||||
}
|
||||
+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