From 9af7cf19da0746c812a0071421b42f56246f5d11 Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Sun, 9 Oct 2022 10:39:19 +0100 Subject: [PATCH] Disable plan editing while it is saving Fixes #271. --- src/showplanner/Item.tsx | 6 +++++- src/showplanner/index.tsx | 4 ++++ src/showplanner/state.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/showplanner/Item.tsx b/src/showplanner/Item.tsx index b4dde60..572de8c 100644 --- a/src/showplanner/Item.tsx +++ b/src/showplanner/Item.tsx @@ -38,6 +38,10 @@ export const Item = memo(function Item({ const id = itemId(x); const isGhost = "ghostid" in x; + const planSaving = useSelector( + (state: RootState) => state.showplan.planSaving + ); + const loadedItem = useSelector( (state: RootState) => column > -1 ? state.mixer.players[column]?.loadedItem : null, @@ -183,7 +187,7 @@ export const Item = memo(function Item({ return data.join("¬"); // Something obscure to split against. } - let isDragDisabled = isGhost; + let isDragDisabled = isGhost || planSaving; if (!process.env.REACT_APP_BAPSICLE_INTERFACE) { isDragDisabled = isDragDisabled || isLoaded; diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index 205d52f..5fe9414 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -100,6 +100,9 @@ const Showplanner: React.FC<{ timeslotId: number | null }> = function({ (state: RootState) => state.showplan.plan !== null, shallowEqual ); + const planSaving = useSelector( + (state: RootState) => state.showplan.planSaving + ); // Tell Modals that #root is the main page content, for accessability reasons. Modal.setAppElement("#root"); @@ -239,6 +242,7 @@ const Showplanner: React.FC<{ timeslotId: number | null }> = function({ onClick={(args) => dispatch(removeItem(timeslotId!, (args.props as any).id)) } + disabled={planSaving} > Remove diff --git a/src/showplanner/state.ts b/src/showplanner/state.ts index 2bf828d..3c6b8e7 100644 --- a/src/showplanner/state.ts +++ b/src/showplanner/state.ts @@ -682,7 +682,7 @@ export const getShowplan = (timeslotId: number): AppThunk => async ( dispatch(showplan.actions.getShowplanSuccess(plan.flat(2))); } catch (e) { console.error(e); - dispatch(showplan.actions.getShowplanError(e.toString())); + dispatch(showplan.actions.getShowplanError(String(e))); } };