Disable plan editing while it is saving

Fixes #271.
This commit is contained in:
Marks Polakovs 2022-10-09 10:39:19 +01:00
parent 2dc3c8cd3c
commit 9af7cf19da
3 changed files with 10 additions and 2 deletions

View file

@ -38,6 +38,10 @@ export const Item = memo(function Item({
const id = itemId(x); const id = itemId(x);
const isGhost = "ghostid" in x; const isGhost = "ghostid" in x;
const planSaving = useSelector(
(state: RootState) => state.showplan.planSaving
);
const loadedItem = useSelector( const loadedItem = useSelector(
(state: RootState) => (state: RootState) =>
column > -1 ? state.mixer.players[column]?.loadedItem : null, 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. return data.join("¬"); // Something obscure to split against.
} }
let isDragDisabled = isGhost; let isDragDisabled = isGhost || planSaving;
if (!process.env.REACT_APP_BAPSICLE_INTERFACE) { if (!process.env.REACT_APP_BAPSICLE_INTERFACE) {
isDragDisabled = isDragDisabled || isLoaded; isDragDisabled = isDragDisabled || isLoaded;

View file

@ -100,6 +100,9 @@ const Showplanner: React.FC<{ timeslotId: number | null }> = function({
(state: RootState) => state.showplan.plan !== null, (state: RootState) => state.showplan.plan !== null,
shallowEqual shallowEqual
); );
const planSaving = useSelector(
(state: RootState) => state.showplan.planSaving
);
// Tell Modals that #root is the main page content, for accessability reasons. // Tell Modals that #root is the main page content, for accessability reasons.
Modal.setAppElement("#root"); Modal.setAppElement("#root");
@ -239,6 +242,7 @@ const Showplanner: React.FC<{ timeslotId: number | null }> = function({
onClick={(args) => onClick={(args) =>
dispatch(removeItem(timeslotId!, (args.props as any).id)) dispatch(removeItem(timeslotId!, (args.props as any).id))
} }
disabled={planSaving}
> >
<FaTrash /> Remove <FaTrash /> Remove
</CtxMenuItem> </CtxMenuItem>

View file

@ -682,7 +682,7 @@ export const getShowplan = (timeslotId: number): AppThunk => async (
dispatch(showplan.actions.getShowplanSuccess(plan.flat(2))); dispatch(showplan.actions.getShowplanSuccess(plan.flat(2)));
} catch (e) { } catch (e) {
console.error(e); console.error(e);
dispatch(showplan.actions.getShowplanError(e.toString())); dispatch(showplan.actions.getShowplanError(String(e)));
} }
}; };