Skip to content

Commit

Permalink
fix: store translated success note as prop
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoo committed Jun 26, 2020
1 parent 774ebe4 commit 5638aee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
13 changes: 5 additions & 8 deletions src/components/with-api-handler/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import apiFetch from '@wordpress/api-fetch';
import { dispatch, select } from '@wordpress/data';
import { createHigherOrderComponent } from '@wordpress/compose';
Expand All @@ -16,6 +17,7 @@ export default () =>
const setInFlightForAsync = () => {
setInFlight( true );
};
const successNote = __( 'Campaign sent on ', 'newspack-newsletters' );
const apiFetchWithErrorHandling = apiRequest => {
setInFlight( true );
return new Promise( ( resolve, reject ) => {
Expand All @@ -24,10 +26,7 @@ export default () =>
const { message } = response;
getNotices().forEach( notice => {
// Don't remove the "Campaign sent" notice.
if (
'success' !== notice.status ||
-1 === notice.content.indexOf( 'Campaign sent' )
) {
if ( 'success' !== notice.status || -1 === notice.content.indexOf( successNote ) ) {
removeNotice( notice.id );
}
} );
Expand All @@ -42,10 +41,7 @@ export default () =>
const { message } = error;
getNotices().forEach( notice => {
// Don't remove the "Campaign sent" notice.
if (
'success' !== notice.status ||
-1 === notice.content.indexOf( 'Campaign sent' )
) {
if ( 'success' !== notice.status || -1 === notice.content.indexOf( successNote ) ) {
removeNotice( notice.id );
}
} );
Expand All @@ -63,6 +59,7 @@ export default () =>
errors={ errors }
setInFlightForAsync={ setInFlightForAsync }
inFlight={ inFlight }
successNote={ successNote }
/>
);
},
Expand Down
3 changes: 1 addition & 2 deletions src/newsletter-editor/editor/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
import { createPortal, useEffect, useState } from '@wordpress/element';
Expand Down Expand Up @@ -90,7 +89,7 @@ const Editor = compose( [
if ( 'publish' === props.status ) {
const dateTime = props.sentDate ? new Date( props.sentDate ).toLocaleString() : '';
// Show an editor notice if the newsletter has been sent.
props.createNotice( 'success', __( 'Campaign sent on ', 'newspack-newsletters' ) + dateTime, {
props.createNotice( 'success', props.successNote + dateTime, {
isDismissible: false,
} );
}
Expand Down

0 comments on commit 5638aee

Please sign in to comment.