TF-3986 Change style for over quota flow when send or save draft email
This commit is contained in:
+19
-20
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/core/error/error_type.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
|
||||
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
|
||||
@@ -7,37 +8,35 @@ import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
extension HandleMessageFailureExtension on ComposerController {
|
||||
|
||||
String getMessageFailure({
|
||||
({String message, ErrorType? errorType}) getMessageFailure({
|
||||
required AppLocalizations appLocalizations,
|
||||
dynamic exception,
|
||||
bool isDraft = false,
|
||||
}) {
|
||||
if (exception is! SetMethodException) {
|
||||
return isDraft
|
||||
final fallbackMessage = isDraft
|
||||
? appLocalizations.warningMessageWhenSaveEmailToDraftsFailure
|
||||
: appLocalizations.warningMessageWhenSendEmailFailure;
|
||||
|
||||
if (exception is! SetMethodException) {
|
||||
return (message: fallbackMessage, errorType: null);
|
||||
}
|
||||
|
||||
for (var error in exception.mapErrors.values) {
|
||||
if (error.type != SetError.tooLarge && error.type != SetError.overQuota) {
|
||||
continue;
|
||||
}
|
||||
for (final error in exception.mapErrors.values) {
|
||||
if (error.type == SetError.tooLarge || error.type == SetError.overQuota) {
|
||||
final message = isDraft
|
||||
? error.toastMessageForSaveEmailAsDraftFailure(
|
||||
appLocalizations: appLocalizations,
|
||||
defaultMessage: fallbackMessage,
|
||||
)
|
||||
: error.toastMessageForSendEmailFailure(
|
||||
appLocalizations: appLocalizations,
|
||||
defaultMessage: fallbackMessage,
|
||||
);
|
||||
|
||||
if (isDraft) {
|
||||
return error.toastMessageForSaveEmailAsDraftFailure(
|
||||
appLocalizations: appLocalizations,
|
||||
defaultMessage:appLocalizations.warningMessageWhenSaveEmailToDraftsFailure,
|
||||
);
|
||||
} else {
|
||||
return error.toastMessageForSendEmailFailure(
|
||||
appLocalizations: appLocalizations,
|
||||
defaultMessage:appLocalizations.warningMessageWhenSendEmailFailure,
|
||||
);
|
||||
return (message: message, errorType: error.type);
|
||||
}
|
||||
}
|
||||
|
||||
return isDraft
|
||||
? appLocalizations.warningMessageWhenSaveEmailToDraftsFailure
|
||||
: appLocalizations.warningMessageWhenSendEmailFailure;
|
||||
return (message: fallbackMessage, errorType: null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user