File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
core/components/subscribe/_actions Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -57,18 +57,21 @@ export const subscribe = async (
5757
5858 const errors = response . data . newsletter . subscribe . errors ;
5959
60- // If there are no errors or the error is that the email already exists, we want to reset the form and show the success message
61- if (
62- ! errors . length ||
63- errors . some ( ( { __typename } ) => __typename === 'CreateSubscriberAlreadyExistsError' )
64- ) {
60+ const subcriberAlreadyExists = errors . some (
61+ ( { __typename } ) => __typename === 'CreateSubscriberAlreadyExistsError' ,
62+ ) ;
63+
64+ // If there are no errors or the subscriber already exists, we want to reset the form and show the success message
65+ // This is for privacy reasons, we don't want to show the error message to the user if they are already subscribed
66+ if ( ! errors . length || subcriberAlreadyExists ) {
6567 return {
6668 lastResult : submission . reply ( ) ,
6769 successMessage : t ( 'subscribedToNewsletter' ) ,
6870 } ;
6971 }
7072
7173 if ( errors . length > 0 ) {
74+ // If there are other errors, we want to show the error message to the user
7275 return {
7376 lastResult : submission . reply ( {
7477 formErrors : errors . map ( ( { __typename } ) => {
You can’t perform that action at this time.
0 commit comments