From ea0a067c0e5d236aaf329e1f376a23b262b31c93 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Thu, 6 Apr 2023 10:18:19 +0200 Subject: [PATCH] change(player): improve multiview assist mount/unmount process --- frontend/app/components/Session/LivePlayer.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/app/components/Session/LivePlayer.tsx b/frontend/app/components/Session/LivePlayer.tsx index 0b3aceaf5..5cc27b51f 100644 --- a/frontend/app/components/Session/LivePlayer.tsx +++ b/frontend/app/components/Session/LivePlayer.tsx @@ -11,6 +11,7 @@ import styles from '../Session_/session.module.css'; import Session from 'App/mstore/types/session'; import withLocationHandlers from 'HOCs/withLocationHandlers'; import APIClient from 'App/api_client'; +import { useLocation } from 'react-router-dom'; interface Props { session: Session; @@ -39,6 +40,7 @@ function LivePlayer({ const openedFromMultiview = query?.get('multi') === 'true' const usedSession = isMultiview ? customSession! : session; let playerInst: ILivePlayerContext['player']; + const location = useLocation(); useEffect(() => { if (!usedSession.sessionId || contextValue.player !== undefined) return; @@ -50,7 +52,6 @@ function LivePlayer({ }, }; if (isEnterprise) { - console.log('building') new APIClient().get('/config/assist/credentials').then(r => r.json()) .then(({ data }) => { const [player, store] = createLiveWebPlayer(sessionWithAgentData, data, (state) => @@ -68,13 +69,16 @@ function LivePlayer({ } }, [usedSession.sessionId]); + // not cleaning up in multiview useEffect(() => { return () => { - playerInst?.clean?.(); - // @ts-ignore default empty - setContextValue(defaultContextValue) + if (!location.pathname.includes('multiview') || !location.pathname.includes(usedSession.sessionId)) { + playerInst?.clean?.(); + // @ts-ignore default empty + setContextValue(defaultContextValue) + } } - }, []) + }, [location.pathname]) // LAYOUT (TODO: local layout state - useContext or something..) useEffect(() => {