Merge pull request #158 from UniversityRadioYork/mstratford-save-tidies
This commit is contained in:
commit
1e5aae0b51
2 changed files with 29 additions and 26 deletions
|
@ -14,18 +14,19 @@ export function ImporterModal(props: ImporterProps) {
|
|||
// 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.
|
||||
useEffect(() => {
|
||||
window.addEventListener(
|
||||
"message",
|
||||
(event) => {
|
||||
if (!event.origin.includes("ury.org.uk")) {
|
||||
return;
|
||||
}
|
||||
if (event.data === "reload_showplan") {
|
||||
props.close();
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
function reloadListener(event: MessageEvent) {
|
||||
if (!event.origin.includes("ury.org.uk")) {
|
||||
return;
|
||||
}
|
||||
if (event.data === "reload_showplan") {
|
||||
props.close();
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("message", reloadListener);
|
||||
return () => {
|
||||
window.removeEventListener("message", reloadListener);
|
||||
};
|
||||
});
|
||||
return (
|
||||
<Modal isOpen={props.isOpen} onRequestClose={props.close}>
|
||||
|
|
|
@ -389,20 +389,22 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
|
|||
// Add support for reloading the show plan from the iFrames.
|
||||
// There is a similar listener in showplanner/ImporterModal.tsx to handle closing the iframe.
|
||||
useEffect(() => {
|
||||
window.addEventListener(
|
||||
"message",
|
||||
(event) => {
|
||||
if (!event.origin.includes("ury.org.uk")) {
|
||||
return;
|
||||
}
|
||||
if (event.data === "reload_showplan") {
|
||||
session.currentTimeslot !== null &&
|
||||
dispatch(getShowplan(session.currentTimeslot.timeslot_id));
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
});
|
||||
function reloadListener(event: MessageEvent) {
|
||||
if (!event.origin.includes("ury.org.uk")) {
|
||||
return;
|
||||
}
|
||||
if (event.data === "reload_showplan") {
|
||||
session.currentTimeslot !== null &&
|
||||
dispatch(getShowplan(session.currentTimeslot.timeslot_id));
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("message", reloadListener);
|
||||
return () => {
|
||||
window.removeEventListener("message", reloadListener);
|
||||
};
|
||||
}, [dispatch, session.currentTimeslot]);
|
||||
|
||||
if (showplan === null) {
|
||||
return (
|
||||
<LoadingDialogue
|
||||
|
|
Loading…
Reference in a new issue