Reload Settings when FROM address modal saved
[MAILPOET-2871]
This commit is contained in:
@@ -5,7 +5,11 @@ import SetFromAddressModal from 'common/set_from_address_modal';
|
|||||||
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
import { GlobalContext, useGlobalContextValue } from 'context/index.jsx';
|
||||||
import Notices from 'notices/notices.jsx';
|
import Notices from 'notices/notices.jsx';
|
||||||
|
|
||||||
const App = () => {
|
type Props = {
|
||||||
|
onRequestClose?: () => void,
|
||||||
|
};
|
||||||
|
|
||||||
|
const App = ({ onRequestClose }: Props) => {
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
|
||||||
// use jQuery since some of the targeted notices are added to the DOM using the old
|
// use jQuery since some of the targeted notices are added to the DOM using the old
|
||||||
@@ -21,16 +25,33 @@ const App = () => {
|
|||||||
<Notices />
|
<Notices />
|
||||||
{ showModal && (
|
{ showModal && (
|
||||||
<SetFromAddressModal
|
<SetFromAddressModal
|
||||||
onRequestClose={() => setShowModal(false)}
|
onRequestClose={() => {
|
||||||
|
setShowModal(false);
|
||||||
|
onRequestClose();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</GlobalContext.Provider>
|
</GlobalContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
App.defaultProps = {
|
||||||
|
onRequestClose: () => {},
|
||||||
|
};
|
||||||
|
|
||||||
// nothing is actually rendered to the container because the <Modal> component uses
|
// nothing is actually rendered to the container because the <Modal> component uses
|
||||||
// ReactDOM.createPortal() but we need an element as a React root on all pages
|
// ReactDOM.createPortal() but we need an element as a React root on all pages
|
||||||
const container = document.getElementById('mailpoet_set_from_address_modal');
|
const container = document.getElementById('mailpoet_set_from_address_modal');
|
||||||
if (container) {
|
if (container) {
|
||||||
ReactDOM.render(<App />, container);
|
ReactDOM.render(
|
||||||
|
<App onRequestClose={() => {
|
||||||
|
// if in Settings, reload page, so the new saved FROM address is loaded
|
||||||
|
const isInSettings = window.location.href.includes('?page=mailpoet-settings');
|
||||||
|
if (isInSettings) {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
container
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user