From 1e53edea2c3adbcbf654c7a8d8383ec4eca4add6 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sun, 6 Jun 2021 15:46:03 +0100 Subject: [PATCH] Fix played status in webstudio --- src/showplanner/state.ts | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/showplanner/state.ts b/src/showplanner/state.ts index ca84add..fb8ba7b 100644 --- a/src/showplanner/state.ts +++ b/src/showplanner/state.ts @@ -260,21 +260,25 @@ export const { export const setItemPlayed = ( itemid: string, - played: boolean, - player: number | null = null + played: boolean ): AppThunk => async (dispatch, getState) => { - if (played) { - return; - } - var weight = -1; - - if (itemid) { - const idx = getState().showplan.plan!.findIndex( - (x) => itemId(x) === itemid - ); - weight = getState().showplan.plan![idx].weight; - } + // The server handles marking things played + // TODO: Add support in BAPSicle for marking things played if (process.env.REACT_APP_BAPSICLE_INTERFACE) { + if (played) { + return; + } + var weight = -1; + var player = null; + + if (itemid) { + const idx = getState().showplan.plan!.findIndex( + (x) => itemId(x) === itemid + ); + weight = getState().showplan.plan![idx].weight; + player = getState().showplan.plan![idx].channel; + } + if (player) { sendBAPSicleChannel({ channel: player, @@ -288,11 +292,8 @@ export const setItemPlayed = ( }); } return; - } else { - dispatch( - showplan.actions.setItemPlayed({ itemId: itemid, played: played }) - ); } + dispatch(showplan.actions.setItemPlayed({ itemId: itemid, played: played })); }; export const moveItem = (