TF-2237 Limit send button clickable only one time
(cherry picked from commit 24ffd7164ee99d4e889814967908ed9c77b38638)
This commit is contained in:
@@ -37,7 +37,7 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
final TextDirection iconAlignment;
|
final TextDirection iconAlignment;
|
||||||
final int? maxLines;
|
final int? maxLines;
|
||||||
final MainAxisSize mainAxisSize;
|
final MainAxisSize mainAxisSize;
|
||||||
final bool? isLoading;
|
final bool isLoading;
|
||||||
|
|
||||||
const TMailButtonWidget({
|
const TMailButtonWidget({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -289,7 +289,7 @@ class TMailButtonWidget extends StatelessWidget {
|
|||||||
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
softWrap: maxLines == 1 ? CommonTextStyle.defaultSoftWrap : null,
|
||||||
),
|
),
|
||||||
SizedBox(width: iconSpace),
|
SizedBox(width: iconSpace),
|
||||||
if (!isLoading!)
|
if (!isLoading)
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
icon!,
|
icon!,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ class ComposerController extends BaseController {
|
|||||||
final hasRequestReadReceipt = false.obs;
|
final hasRequestReadReceipt = false.obs;
|
||||||
final ccRecipientState = PrefixRecipientState.disabled.obs;
|
final ccRecipientState = PrefixRecipientState.disabled.obs;
|
||||||
final bccRecipientState = PrefixRecipientState.disabled.obs;
|
final bccRecipientState = PrefixRecipientState.disabled.obs;
|
||||||
|
final isSendEmailLoading = false.obs;
|
||||||
|
|
||||||
final LocalFilePickerInteractor _localFilePickerInteractor;
|
final LocalFilePickerInteractor _localFilePickerInteractor;
|
||||||
final DeviceInfoPlugin _deviceInfoPlugin;
|
final DeviceInfoPlugin _deviceInfoPlugin;
|
||||||
@@ -288,6 +289,9 @@ class ComposerController extends BaseController {
|
|||||||
} else if (failure is GetEmailContentFailure ||
|
} else if (failure is GetEmailContentFailure ||
|
||||||
failure is TransformHtmlEmailContentFailure) {
|
failure is TransformHtmlEmailContentFailure) {
|
||||||
emailContentsViewState.value = Left(failure);
|
emailContentsViewState.value = Left(failure);
|
||||||
|
if (isSendEmailLoading.isTrue) {
|
||||||
|
isSendEmailLoading.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,8 +791,14 @@ class ComposerController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendEmailAction(BuildContext context) async {
|
void sendEmailAction(BuildContext context) async {
|
||||||
|
if (isSendEmailLoading.isTrue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
clearFocusEditor(context);
|
clearFocusEditor(context);
|
||||||
|
|
||||||
|
isSendEmailLoading.value = true;
|
||||||
|
|
||||||
if (toEmailAddressController.text.isNotEmpty
|
if (toEmailAddressController.text.isNotEmpty
|
||||||
|| ccEmailAddressController.text.isNotEmpty
|
|| ccEmailAddressController.text.isNotEmpty
|
||||||
|| bccEmailAddressController.text.isNotEmpty) {
|
|| bccEmailAddressController.text.isNotEmpty) {
|
||||||
@@ -800,7 +810,7 @@ class ComposerController extends BaseController {
|
|||||||
showConfirmDialogAction(context,
|
showConfirmDialogAction(context,
|
||||||
AppLocalizations.of(context).message_dialog_send_email_without_recipient,
|
AppLocalizations.of(context).message_dialog_send_email_without_recipient,
|
||||||
AppLocalizations.of(context).add_recipients,
|
AppLocalizations.of(context).add_recipients,
|
||||||
onConfirmAction: () => {},
|
onConfirmAction: () => {isSendEmailLoading.value = false},
|
||||||
title: AppLocalizations.of(context).sending_failed,
|
title: AppLocalizations.of(context).sending_failed,
|
||||||
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
||||||
hasCancelButton: false);
|
hasCancelButton: false);
|
||||||
@@ -819,6 +829,7 @@ class ComposerController extends BaseController {
|
|||||||
toAddressExpandMode.value = ExpandMode.EXPAND;
|
toAddressExpandMode.value = ExpandMode.EXPAND;
|
||||||
ccAddressExpandMode.value = ExpandMode.EXPAND;
|
ccAddressExpandMode.value = ExpandMode.EXPAND;
|
||||||
bccAddressExpandMode.value = ExpandMode.EXPAND;
|
bccAddressExpandMode.value = ExpandMode.EXPAND;
|
||||||
|
isSendEmailLoading.value = false;
|
||||||
},
|
},
|
||||||
title: AppLocalizations.of(context).sending_failed,
|
title: AppLocalizations.of(context).sending_failed,
|
||||||
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
||||||
@@ -831,6 +842,7 @@ class ComposerController extends BaseController {
|
|||||||
AppLocalizations.of(context).message_dialog_send_email_without_a_subject,
|
AppLocalizations.of(context).message_dialog_send_email_without_a_subject,
|
||||||
AppLocalizations.of(context).send_anyway,
|
AppLocalizations.of(context).send_anyway,
|
||||||
onConfirmAction: () => _handleSendMessages(context),
|
onConfirmAction: () => _handleSendMessages(context),
|
||||||
|
onCancelAction: () => {isSendEmailLoading.value = false},
|
||||||
title: AppLocalizations.of(context).empty_subject,
|
title: AppLocalizations.of(context).empty_subject,
|
||||||
icon: SvgPicture.asset(_imagePaths.icEmpty, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icEmpty, fit: BoxFit.fill),
|
||||||
);
|
);
|
||||||
@@ -842,7 +854,7 @@ class ComposerController extends BaseController {
|
|||||||
context,
|
context,
|
||||||
AppLocalizations.of(context).messageDialogSendEmailUploadingAttachment,
|
AppLocalizations.of(context).messageDialogSendEmailUploadingAttachment,
|
||||||
AppLocalizations.of(context).got_it,
|
AppLocalizations.of(context).got_it,
|
||||||
onConfirmAction: () => {},
|
onConfirmAction: () => {isSendEmailLoading.value = false},
|
||||||
title: AppLocalizations.of(context).sending_failed,
|
title: AppLocalizations.of(context).sending_failed,
|
||||||
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
||||||
hasCancelButton: false);
|
hasCancelButton: false);
|
||||||
@@ -855,7 +867,7 @@ class ComposerController extends BaseController {
|
|||||||
AppLocalizations.of(context).message_dialog_send_email_exceeds_maximum_size(
|
AppLocalizations.of(context).message_dialog_send_email_exceeds_maximum_size(
|
||||||
filesize(mailboxDashBoardController.maxSizeAttachmentsPerEmail?.value ?? 0, 0)),
|
filesize(mailboxDashBoardController.maxSizeAttachmentsPerEmail?.value ?? 0, 0)),
|
||||||
AppLocalizations.of(context).got_it,
|
AppLocalizations.of(context).got_it,
|
||||||
onConfirmAction: () => {},
|
onConfirmAction: () => {isSendEmailLoading.value = false},
|
||||||
title: AppLocalizations.of(context).sending_failed,
|
title: AppLocalizations.of(context).sending_failed,
|
||||||
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
icon: SvgPicture.asset(_imagePaths.icSendToastError, fit: BoxFit.fill),
|
||||||
hasCancelButton: false);
|
hasCancelButton: false);
|
||||||
@@ -1110,7 +1122,7 @@ class ComposerController extends BaseController {
|
|||||||
AppLocalizations.of(currentContext!).message_dialog_upload_attachments_exceeds_maximum_size(
|
AppLocalizations.of(currentContext!).message_dialog_upload_attachments_exceeds_maximum_size(
|
||||||
filesize(mailboxDashBoardController.maxSizeAttachmentsPerEmail?.value ?? 0, 0)),
|
filesize(mailboxDashBoardController.maxSizeAttachmentsPerEmail?.value ?? 0, 0)),
|
||||||
AppLocalizations.of(currentContext!).got_it,
|
AppLocalizations.of(currentContext!).got_it,
|
||||||
onConfirmAction: () => {},
|
onConfirmAction: () => {isSendEmailLoading.value = false},
|
||||||
title: AppLocalizations.of(currentContext!).maximum_files_size,
|
title: AppLocalizations.of(currentContext!).maximum_files_size,
|
||||||
hasCancelButton: false);
|
hasCancelButton: false);
|
||||||
}
|
}
|
||||||
@@ -1454,11 +1466,13 @@ class ComposerController extends BaseController {
|
|||||||
if (PlatformInfo.isWeb) {
|
if (PlatformInfo.isWeb) {
|
||||||
_closeComposerWeb(result: result);
|
_closeComposerWeb(result: result);
|
||||||
} else {
|
} else {
|
||||||
|
isSendEmailLoading.value = false;
|
||||||
popBack(result: result);
|
popBack(result: result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _closeComposerWeb({dynamic result}) {
|
void _closeComposerWeb({dynamic result}) {
|
||||||
|
isSendEmailLoading.value = false;
|
||||||
mailboxDashBoardController.closeComposerOverlay(result: result);
|
mailboxDashBoardController.closeComposerOverlay(result: result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1803,7 +1817,7 @@ class ComposerController extends BaseController {
|
|||||||
AppLocalizations.of(currentContext!).message_dialog_upload_attachments_exceeds_maximum_size(
|
AppLocalizations.of(currentContext!).message_dialog_upload_attachments_exceeds_maximum_size(
|
||||||
filesize(mailboxDashBoardController.maxSizeAttachmentsPerEmail?.value ?? 0, 0)),
|
filesize(mailboxDashBoardController.maxSizeAttachmentsPerEmail?.value ?? 0, 0)),
|
||||||
AppLocalizations.of(currentContext!).got_it,
|
AppLocalizations.of(currentContext!).got_it,
|
||||||
onConfirmAction: () => {},
|
onConfirmAction: () => {isSendEmailLoading.value = false},
|
||||||
title: AppLocalizations.of(currentContext!).maximum_files_size,
|
title: AppLocalizations.of(currentContext!).maximum_files_size,
|
||||||
hasCancelButton: false);
|
hasCancelButton: false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class BottomBarComposerWidget extends StatelessWidget {
|
|||||||
final VoidCallback saveToDraftAction;
|
final VoidCallback saveToDraftAction;
|
||||||
final VoidCallback sendMessageAction;
|
final VoidCallback sendMessageAction;
|
||||||
final OnRequestReadReceiptAction? requestReadReceiptAction;
|
final OnRequestReadReceiptAction? requestReadReceiptAction;
|
||||||
final bool? isSending;
|
final bool isSending;
|
||||||
|
|
||||||
final _imagePaths = Get.find<ImagePaths>();
|
final _imagePaths = Get.find<ImagePaths>();
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class BottomBarComposerWidget extends StatelessWidget {
|
|||||||
required this.saveToDraftAction,
|
required this.saveToDraftAction,
|
||||||
required this.sendMessageAction,
|
required this.sendMessageAction,
|
||||||
this.requestReadReceiptAction,
|
this.requestReadReceiptAction,
|
||||||
this.isSending,
|
this.isSending = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -128,7 +128,7 @@ class BottomBarComposerWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: BottomBarComposerWidgetStyle.sendButtonSpace),
|
const SizedBox(width: BottomBarComposerWidgetStyle.sendButtonSpace),
|
||||||
TMailButtonWidget(
|
TMailButtonWidget(
|
||||||
text: isSending! ? AppLocalizations.of(context).sending : AppLocalizations.of(context).send,
|
text: isSending ? AppLocalizations.of(context).sending : AppLocalizations.of(context).send,
|
||||||
icon: _imagePaths.icSend,
|
icon: _imagePaths.icSend,
|
||||||
iconAlignment: TextDirection.rtl,
|
iconAlignment: TextDirection.rtl,
|
||||||
padding: BottomBarComposerWidgetStyle.sendButtonPadding,
|
padding: BottomBarComposerWidgetStyle.sendButtonPadding,
|
||||||
|
|||||||
Reference in New Issue
Block a user