hotfix: Do not add Reply-To to recipients field collapsed when unfocus

(cherry picked from commit aa0c27ce1c9d7fdd579d0f25c6b7d8f4b50adf70)
This commit is contained in:
dab246
2025-10-10 15:28:23 +07:00
committed by Dat H. Pham
parent c9cb68f3ef
commit bddf29c604
4 changed files with 44 additions and 27 deletions
@@ -599,9 +599,7 @@ class ComposerController extends BaseController
richTextMobileTabletController?.richTextController.hideRichTextView();
}
autoCreateEmailTag();
if (isRecipientsNotEmpty) {
hideAllRecipients();
}
triggerHideRecipientsFiledsWhenUnfocus();
}
}
@@ -720,8 +718,8 @@ class ComposerController extends BaseController
listBccEmailAddress = List.from(recipients.bcc);
listReplyToEmailAddress = List.from(recipients.replyTo);
if (isRecipientsNotEmpty) {
hideAllRecipients();
if (isRecipientsWithoutReplyToNotEmpty) {
hideAllRecipientsFields();
isInitialRecipient.value = true;
} else {
toRecipientState.value = PrefixRecipientState.enabled;
@@ -792,7 +790,7 @@ class ComposerController extends BaseController
return;
}
if (listEmailAddressInvalid.isNotEmpty) {
if (existEmailAddressInvalid) {
MessageDialogActionManager().showConfirmDialogAction(context,
appLocalizations.message_dialog_send_email_with_email_address_invalid,
appLocalizations.fix_email_addresses,
@@ -1440,9 +1438,7 @@ class ComposerController extends BaseController
void clickOutsideComposer(BuildContext context) {
clearFocus(context);
if (isRecipientsNotEmpty) {
hideAllRecipients();
}
triggerHideRecipientsFiledsWhenUnfocus();
}
void _closeComposerAction({dynamic result, bool closeOverlays = false}) {
@@ -1712,9 +1708,7 @@ class ComposerController extends BaseController
richTextMobileTabletController?.richTextController.showDeviceKeyboard);
}
autoCreateEmailTag();
if (isRecipientsNotEmpty) {
hideAllRecipients();
}
triggerHideRecipientsFiledsWhenUnfocus();
}
void _onChangeCursorOnMobile(List<int>? coordinates, BuildContext context) {
@@ -1846,9 +1840,7 @@ class ComposerController extends BaseController
popBack();
}
autoCreateEmailTag();
if (isRecipientsNotEmpty) {
hideAllRecipients();
}
triggerHideRecipientsFiledsWhenUnfocus();
}
FocusNode? getNextFocusOfToEmailAddress() {
@@ -128,7 +128,7 @@ class ComposerView extends GetWidget<ComposerController> {
Obx(() {
if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled) {
return RecipientsCollapsedComposerWidget(
listEmailAddress: controller.allListEmailAddress,
listEmailAddress: controller.allListEmailAddressWithoutReplyTo,
margin: ComposerStyle.mobileRecipientMargin,
onShowAllRecipientsAction: controller.showFullRecipients,
);
@@ -307,7 +307,7 @@ class ComposerView extends GetWidget<ComposerController> {
Obx(() {
if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled) {
return RecipientsCollapsedComposerWidget(
listEmailAddress: controller.allListEmailAddress,
listEmailAddress: controller.allListEmailAddressWithoutReplyTo,
margin: ComposerStyle.mobileRecipientMargin,
onShowAllRecipientsAction: controller.showFullRecipients,
);
@@ -122,7 +122,7 @@ class ComposerView extends GetWidget<ComposerController> {
),
if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled)
RecipientsCollapsedComposerWidget(
listEmailAddress: controller.allListEmailAddress,
listEmailAddress: controller.allListEmailAddressWithoutReplyTo,
margin: ComposerStyle.mobileRecipientMargin,
onShowAllRecipientsAction: controller.showFullRecipients,
),
@@ -349,7 +349,7 @@ class ComposerView extends GetWidget<ComposerController> {
),
if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled)
RecipientsCollapsedComposerWidget(
listEmailAddress: controller.allListEmailAddress,
listEmailAddress: controller.allListEmailAddressWithoutReplyTo,
margin: ComposerStyle.desktopRecipientMargin,
onShowAllRecipientsAction: controller.showFullRecipients,
),
@@ -617,7 +617,7 @@ class ComposerView extends GetWidget<ComposerController> {
),
if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled)
RecipientsCollapsedComposerWidget(
listEmailAddress: controller.allListEmailAddress,
listEmailAddress: controller.allListEmailAddressWithoutReplyTo,
margin: ComposerStyle.desktopRecipientMargin,
onShowAllRecipientsAction: controller.showFullRecipients,
),
@@ -12,17 +12,25 @@ extension HandleRecipientsCollapsedExtensions on ComposerController {
listBccEmailAddress +
listReplyToEmailAddress;
List<EmailAddress> get listEmailAddressInvalid => allListEmailAddress
.where(
List<EmailAddress> get allListEmailAddressWithoutReplyTo =>
listToEmailAddress +
listCcEmailAddress +
listBccEmailAddress;
bool get existEmailAddressInvalid => allListEmailAddress
.any(
(emailAddress) => !EmailUtils.isEmailAddressValid(
emailAddress.emailAddress,
),
)
.toList();
);
bool get isRecipientsNotEmpty => listToEmailAddress.isNotEmpty ||
bool get isRecipientsWithoutReplyToNotEmpty => listToEmailAddress.isNotEmpty ||
listCcEmailAddress.isNotEmpty ||
listBccEmailAddress.isNotEmpty ||
listBccEmailAddress.isNotEmpty;
bool get isRecipientsEmptyExceptReplyTo => listToEmailAddress.isEmpty &&
listCcEmailAddress.isEmpty &&
listBccEmailAddress.isEmpty &&
listReplyToEmailAddress.isNotEmpty;
void showFullRecipients() {
@@ -90,7 +98,15 @@ extension HandleRecipientsCollapsedExtensions on ComposerController {
}
}
void hideAllRecipients() {
void triggerHideRecipientsFiledsWhenUnfocus() {
if (isRecipientsEmptyExceptReplyTo) {
hideAllRecipientsFieldsExceptTo();
} else if (isRecipientsWithoutReplyToNotEmpty) {
hideAllRecipientsFields();
}
}
void hideAllRecipientsFields() {
fromRecipientState.value = PrefixRecipientState.disabled;
toRecipientState.value = PrefixRecipientState.disabled;
ccRecipientState.value = PrefixRecipientState.disabled;
@@ -98,4 +114,13 @@ extension HandleRecipientsCollapsedExtensions on ComposerController {
replyToRecipientState.value = PrefixRecipientState.disabled;
recipientsCollapsedState.value = PrefixRecipientState.enabled;
}
void hideAllRecipientsFieldsExceptTo() {
toRecipientState.value = PrefixRecipientState.enabled;
fromRecipientState.value = PrefixRecipientState.disabled;
ccRecipientState.value = PrefixRecipientState.disabled;
bccRecipientState.value = PrefixRecipientState.disabled;
replyToRecipientState.value = PrefixRecipientState.disabled;
recipientsCollapsedState.value = PrefixRecipientState.disabled;
}
}