diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx
index cd66aeb..adf3c96 100644
--- a/src/showplanner/index.tsx
+++ b/src/showplanner/index.tsx
@@ -320,10 +320,10 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
useBeforeunload((event) => event.preventDefault());
useEffect(() => {
- if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
- dispatch(getShowplan());
+ if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
+ dispatch(getShowplan(timeslotId));
}
- }, [dispatch]);
+ }, [dispatch, timeslotId]);
function toggleSidebar() {
var element = document.getElementById("sidebar");
@@ -386,6 +386,8 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
command: "ADD",
newItem: newItem,
});
+ } else {
+ dispatch(addItem(timeslotId, newItem));
}
increment(null);
} else {
@@ -415,12 +417,17 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {
e: any,
data: { id: string; column: number; index: number }
) {
- sendBAPSicleChannel({
- channel: data.column,
- command: "REMOVE",
- weight: data.index,
- });
+ if (process.env.REACT_APP_BAPSICLE_INTERFACE) {
+ sendBAPSicleChannel({
+ channel: data.column,
+ command: "REMOVE",
+ weight: data.index,
+ });
+ } else {
+ dispatch(removeItem(timeslotId, data.id));
+ }
}
+
async function onCtxUnPlayedClick(
e: any,
data: { id: string; column: number; index: number }
@@ -431,17 +438,16 @@ 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(() => {
- if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
- 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));
- }
+ 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));
+ }
+ }
+ if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
window.addEventListener("message", reloadListener);
return () => {
window.removeEventListener("message", reloadListener);
@@ -454,7 +460,7 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) {