Make only one request to API
This commit is contained in:
committed by
M. Shull
parent
529a0fef7b
commit
a2700246f0
@@ -28,6 +28,7 @@ const messages = {
|
|||||||
|
|
||||||
const SendingStatus = (props) => {
|
const SendingStatus = (props) => {
|
||||||
const newsletterId = props.match.params.id;
|
const newsletterId = props.match.params.id;
|
||||||
|
const [isLoading, setIsLoading] = React.useState(true);
|
||||||
const [newsletterSubject, setNewsletterSubject] = React.useState('');
|
const [newsletterSubject, setNewsletterSubject] = React.useState('');
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -39,9 +40,11 @@ const SendingStatus = (props) => {
|
|||||||
id: newsletterId,
|
id: newsletterId,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.done(res => setNewsletterSubject(res.data.subject))
|
.done((res) => {
|
||||||
|
setNewsletterSubject(res.data.subject);
|
||||||
|
setIsLoading(false);
|
||||||
|
})
|
||||||
.fail((res) => {
|
.fail((res) => {
|
||||||
setNewsletterSubject('');
|
|
||||||
MailPoet.Notice.showApiErrorNotice(res);
|
MailPoet.Notice.showApiErrorNotice(res);
|
||||||
});
|
});
|
||||||
}, [newsletterId]);
|
}, [newsletterId]);
|
||||||
@@ -53,6 +56,7 @@ const SendingStatus = (props) => {
|
|||||||
newsletterId={newsletterId}
|
newsletterId={newsletterId}
|
||||||
newsletterSubject={newsletterSubject}
|
newsletterSubject={newsletterSubject}
|
||||||
/>
|
/>
|
||||||
|
{!isLoading && (
|
||||||
<Listing
|
<Listing
|
||||||
limit={window.mailpoet_listing_per_page}
|
limit={window.mailpoet_listing_per_page}
|
||||||
location={props.location}
|
location={props.location}
|
||||||
@@ -70,6 +74,7 @@ const SendingStatus = (props) => {
|
|||||||
CronMixin.checkCronStatus(state);
|
CronMixin.checkCronStatus(state);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user