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