Merge pull request #158 from UniversityRadioYork/mstratford-save-tidies

This commit is contained in:
Marks Polakovs 2020-11-02 18:55:23 +00:00 committed by GitHub
commit 1e5aae0b51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 26 deletions

View file

@ -14,18 +14,19 @@ export function ImporterModal(props: ImporterProps) {
// Add support for closing the modal when the importer wants to reload the show plan. // Add support for closing the modal when the importer wants to reload the show plan.
// There is a similar listener in showplanner/index.tsx to actually reload the show plan. // There is a similar listener in showplanner/index.tsx to actually reload the show plan.
useEffect(() => { useEffect(() => {
window.addEventListener( function reloadListener(event: MessageEvent) {
"message", if (!event.origin.includes("ury.org.uk")) {
(event) => { return;
if (!event.origin.includes("ury.org.uk")) { }
return; if (event.data === "reload_showplan") {
} props.close();
if (event.data === "reload_showplan") { }
props.close(); }
}
}, window.addEventListener("message", reloadListener);
false return () => {
); window.removeEventListener("message", reloadListener);
};
}); });
return ( return (
<Modal isOpen={props.isOpen} onRequestClose={props.close}> <Modal isOpen={props.isOpen} onRequestClose={props.close}>

View file

@ -389,20 +389,22 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
// Add support for reloading the show plan from the iFrames. // Add support for reloading the show plan from the iFrames.
// There is a similar listener in showplanner/ImporterModal.tsx to handle closing the iframe. // There is a similar listener in showplanner/ImporterModal.tsx to handle closing the iframe.
useEffect(() => { useEffect(() => {
window.addEventListener( function reloadListener(event: MessageEvent) {
"message", if (!event.origin.includes("ury.org.uk")) {
(event) => { return;
if (!event.origin.includes("ury.org.uk")) { }
return; if (event.data === "reload_showplan") {
} session.currentTimeslot !== null &&
if (event.data === "reload_showplan") { dispatch(getShowplan(session.currentTimeslot.timeslot_id));
session.currentTimeslot !== null && }
dispatch(getShowplan(session.currentTimeslot.timeslot_id)); }
}
}, window.addEventListener("message", reloadListener);
false return () => {
); window.removeEventListener("message", reloadListener);
}); };
}, [dispatch, session.currentTimeslot]);
if (showplan === null) { if (showplan === null) {
return ( return (
<LoadingDialogue <LoadingDialogue