Merge pull request #272 from UniversityRadioYork/marks/disable-editing-while-saving

This commit is contained in:
Marks Polakovs 2023-05-02 23:47:50 +01:00 committed by GitHub
commit 32e32cc9d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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)));
} }
}; };