From 3a38d40469019b16bbd3b9d462fdc7c4af991b89 Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 29 Mar 2022 16:39:41 +0700 Subject: [PATCH] TF-369 Fix auto close email when download attachment in browser with small screen --- .../email/presentation/email_controller.dart | 17 ++++++----------- lib/features/email/presentation/email_view.dart | 2 +- lib/l10n/intl_messages.arb | 8 +++++++- lib/main/localizations/app_localizations.dart | 7 +++++++ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/features/email/presentation/email_controller.dart b/lib/features/email/presentation/email_controller.dart index bdc6c8510..9788bf317 100644 --- a/lib/features/email/presentation/email_controller.dart +++ b/lib/features/email/presentation/email_controller.dart @@ -140,8 +140,6 @@ class EmailController extends BaseController { _moveToMailboxSuccess(success); } else if (success is MarkAsStarEmailSuccess) { _markAsEmailStarSuccess(success); - } else if (success is DownloadAttachmentForWebSuccess) { - _downloadAttachmentForWebSuccessAction(success); } }); } @@ -308,28 +306,25 @@ class EmailController extends BaseController { } } - void downloadAttachmentForWeb(Attachment attachment) { - _downloadAttachmentForWebAction(attachment); + void downloadAttachmentForWeb(BuildContext context, Attachment attachment) { + _downloadAttachmentForWebAction(context, attachment); } - void _downloadAttachmentForWebAction(Attachment attachment) async { + void _downloadAttachmentForWebAction(BuildContext context, Attachment attachment) async { final accountId = mailboxDashBoardController.accountId.value; if (accountId != null && mailboxDashBoardController.sessionCurrent != null) { final baseDownloadUrl = mailboxDashBoardController.sessionCurrent!.getDownloadUrl(); + _appToast.showToast(AppLocalizations.of(context).your_download_has_started); consumeState(_downloadAttachmentForWebInteractor.execute(attachment, accountId, baseDownloadUrl)); } } void _downloadAttachmentForWebFailureAction(Failure failure) { - if (failure is DownloadAttachmentForWebFailure) { - popBack(); + if (failure is DownloadAttachmentForWebFailure && currentContext != null) { + _appToast.showErrorToast(AppLocalizations.of(currentContext!).attachment_download_failed); } } - void _downloadAttachmentForWebSuccessAction(Success success) async { - popBack(); - } - void moveToMailboxAction(PresentationEmail email) async { final currentMailbox = mailboxDashBoardController.selectedMailbox.value; final accountId = mailboxDashBoardController.accountId.value; diff --git a/lib/features/email/presentation/email_view.dart b/lib/features/email/presentation/email_view.dart index 2e96d9080..9d6d96277 100644 --- a/lib/features/email/presentation/email_view.dart +++ b/lib/features/email/presentation/email_view.dart @@ -450,7 +450,7 @@ class EmailView extends GetView with UserSettingPopupMenuMixin { ..onExpandAttachmentActionClick(() => emailController.toggleDisplayAttachmentsAction()) ..onDownloadAttachmentFileActionClick((attachment) { if (kIsWeb) { - emailController.downloadAttachmentForWeb(attachment); + emailController.downloadAttachmentForWeb(context, attachment); } else { if (Platform.isAndroid) { emailController.downloadAttachments(context, [attachment]); diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb index 7831e2ac5..7136d6ea7 100644 --- a/lib/l10n/intl_messages.arb +++ b/lib/l10n/intl_messages.arb @@ -1,5 +1,5 @@ { - "@@last_modified": "2022-03-29T13:00:02.017403", + "@@last_modified": "2022-03-29T16:34:59.741046", "initializing_data": "Initializing data...", "@initializing_data": { "type": "text", @@ -899,5 +899,11 @@ "type": "text", "placeholders_order": [], "placeholders": {} + }, + "your_download_has_started": "Your download has started", + "@your_download_has_started": { + "type": "text", + "placeholders_order": [], + "placeholders": {} } } \ No newline at end of file diff --git a/lib/main/localizations/app_localizations.dart b/lib/main/localizations/app_localizations.dart index 763947f42..dd8038107 100644 --- a/lib/main/localizations/app_localizations.dart +++ b/lib/main/localizations/app_localizations.dart @@ -956,4 +956,11 @@ class AppLocalizations { name: 'the_total_size_of_attachments_in_an_email_exceeds_the_limit' ); } + + String get your_download_has_started { + return Intl.message( + 'Your download has started', + name: 'your_download_has_started' + ); + } } \ No newline at end of file