TF-2907 Handle error correctly when perform reply event action
This commit is contained in:
@@ -74,7 +74,11 @@ class CalendarEventAPI {
|
||||
throw NotAcceptableCalendarEventException();
|
||||
}
|
||||
|
||||
return calendarEventAcceptResponse;
|
||||
if (calendarEventAcceptResponse.accepted?.isNotEmpty == true) {
|
||||
return calendarEventAcceptResponse;
|
||||
} else {
|
||||
throw CannotReplyCalendarEventException(mapErrors: calendarEventAcceptResponse.notAccepted);
|
||||
}
|
||||
}
|
||||
|
||||
Future<CalendarEventMaybeResponse> maybeEventInvitation(
|
||||
@@ -102,7 +106,11 @@ class CalendarEventAPI {
|
||||
throw NotMaybeableCalendarEventException();
|
||||
}
|
||||
|
||||
return calendarEventMaybeResponse;
|
||||
if (calendarEventMaybeResponse.maybe?.isNotEmpty == true) {
|
||||
return calendarEventMaybeResponse;
|
||||
} else {
|
||||
throw CannotReplyCalendarEventException(mapErrors: calendarEventMaybeResponse.notMaybe);
|
||||
}
|
||||
}
|
||||
|
||||
Future<CalendarEventRejectResponse> rejectEventInvitation(
|
||||
@@ -130,6 +138,10 @@ class CalendarEventAPI {
|
||||
throw NotRejectableCalendarEventException();
|
||||
}
|
||||
|
||||
return calendarEventRejectResponse;
|
||||
if (calendarEventRejectResponse.rejected?.isNotEmpty == true) {
|
||||
return calendarEventRejectResponse;
|
||||
} else {
|
||||
throw CannotReplyCalendarEventException(mapErrors: calendarEventRejectResponse.notRejected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
|
||||
class NotFoundCalendarEventException implements Exception {}
|
||||
|
||||
class NotParsableCalendarEventException implements Exception {}
|
||||
@@ -8,3 +11,9 @@ class NotAcceptableCalendarEventException implements Exception {}
|
||||
class NotMaybeableCalendarEventException implements Exception {}
|
||||
|
||||
class NotRejectableCalendarEventException implements Exception {}
|
||||
|
||||
class CannotReplyCalendarEventException implements Exception {
|
||||
final Map<Id, SetError>? mapErrors;
|
||||
|
||||
CannotReplyCalendarEventException({this.mapErrors});
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import 'package:tmail_ui_user/features/base/mixin/app_loader_mixin.dart';
|
||||
import 'package:tmail_ui_user/features/base/state/button_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/extensions/email_action_type_extension.dart';
|
||||
import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/exceptions/calendar_event_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/exceptions/email_exceptions.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/extensions/list_attachments_extension.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/model/detailed_email.dart';
|
||||
@@ -255,7 +256,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
_showMessageWhenEmailPrintingFailed(failure);
|
||||
} else if (failure is CalendarEventReplyFailure
|
||||
|| failure is StoreEventAttendanceStatusFailure) {
|
||||
_calendarEventFailure();
|
||||
_calendarEventFailure(failure);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1752,12 +1753,26 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
success.eventActionType.getToastMessageSuccess(currentContext!));
|
||||
}
|
||||
|
||||
void _calendarEventFailure() {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).eventReplyWasSentUnsuccessfully);
|
||||
void _calendarEventFailure(Failure failure) {
|
||||
if (currentOverlayContext == null || currentContext == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (failure is CalendarEventReplyFailure && failure.exception is CannotReplyCalendarEventException) {
|
||||
final replyEventException = failure.exception as CannotReplyCalendarEventException;
|
||||
|
||||
if (replyEventException.mapErrors?.isNotEmpty == true) {
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
replyEventException.mapErrors!.values.first.description
|
||||
?? AppLocalizations.of(currentContext!).eventReplyWasSentUnsuccessfully);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
appToast.showToastErrorMessage(
|
||||
currentOverlayContext!,
|
||||
AppLocalizations.of(currentContext!).eventReplyWasSentUnsuccessfully);
|
||||
}
|
||||
|
||||
void _downloadMessageAsEML(PresentationEmail presentationEmail) {
|
||||
|
||||
Reference in New Issue
Block a user