diff --git a/frontend/app/components/Session/Player/LivePlayer/AssistSessionsTabs/AssistSessionsTabs.tsx b/frontend/app/components/Session/Player/LivePlayer/AssistSessionsTabs/AssistSessionsTabs.tsx index 07311665a..b156ee3f4 100644 --- a/frontend/app/components/Session/Player/LivePlayer/AssistSessionsTabs/AssistSessionsTabs.tsx +++ b/frontend/app/components/Session/Player/LivePlayer/AssistSessionsTabs/AssistSessionsTabs.tsx @@ -6,18 +6,20 @@ import { observer } from 'mobx-react-lite'; import { useHistory } from 'react-router-dom'; import { multiview, liveSession, withSiteId } from 'App/routes'; import { connect } from 'react-redux'; +import { PlayerContext, ILivePlayerContext } from 'App/components/Session/playerContext'; interface ITab { onClick?: () => void; classNames?: string; children: React.ReactNode; style?: Record; + isDisabled?: boolean; } const Tab = (props: ITab) => (
{props.children} @@ -25,7 +27,7 @@ const Tab = (props: ITab) => ( ); export const InactiveTab = React.memo((props: Omit) => ( - + )); @@ -44,6 +46,10 @@ const CurrentTab = React.memo(() => ( function AssistTabs({ session, siteId }: { session: Record; siteId: string }) { const history = useHistory(); + const { store } = React.useContext(PlayerContext) as unknown as ILivePlayerContext + const { recordingState, calling, remoteControl } = store.get() + const isDisabled = recordingState !== 0 || calling !== 0 || remoteControl !== 0 + const { assistMultiviewStore } = useStore(); const placeholder = new Array(4 - assistMultiviewStore.sessions.length).fill(0); @@ -55,28 +61,30 @@ function AssistTabs({ session, siteId }: { session: Record; siteId: }, []); const openGrid = () => { + if (isDisabled) return; const sessionIdQuery = encodeURIComponent(assistMultiviewStore.sessions.map((s) => s.sessionId).join(',')); return history.push(withSiteId(multiview(sessionIdQuery), siteId)); }; const openLiveSession = (sessionId: string) => { + if (isDisabled) return; assistMultiviewStore.setActiveSession(sessionId); history.push(withSiteId(liveSession(sessionId), siteId)); }; return ( -
+
{assistMultiviewStore.sortedSessions.map((session: { key: number, sessionId: string }) => ( {assistMultiviewStore.isActive(session.sessionId) ? ( ) : ( - openLiveSession(session.sessionId)} /> + openLiveSession(session.sessionId)} /> )} ))} {placeholder.map((_, i) => ( - + ))}