From 8d34afebc48fe6a8c9e655f8a8d011ce1ba251d8 Mon Sep 17 00:00:00 2001 From: Delirium Date: Wed, 5 Apr 2023 18:10:34 +0200 Subject: [PATCH] fix assist cleanup (#1111) * change(player): cleanup assist sockets on unmount * change(player): remove memo * change(player): fix unmount? --- frontend/app/components/Session/LivePlayer.tsx | 11 +++++++---- frontend/app/components/Session/LiveSession.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/app/components/Session/LivePlayer.tsx b/frontend/app/components/Session/LivePlayer.tsx index 8b884074c..0b3aceaf5 100644 --- a/frontend/app/components/Session/LivePlayer.tsx +++ b/frontend/app/components/Session/LivePlayer.tsx @@ -38,9 +38,9 @@ function LivePlayer({ const [fullView, setFullView] = useState(false); const openedFromMultiview = query?.get('multi') === 'true' const usedSession = isMultiview ? customSession! : session; + let playerInst: ILivePlayerContext['player']; useEffect(() => { - let playerInst: ILivePlayerContext['player']; if (!usedSession.sessionId || contextValue.player !== undefined) return; const sessionWithAgentData = { ...usedSession, @@ -50,6 +50,7 @@ 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) => @@ -65,13 +66,15 @@ function LivePlayer({ setContextValue({ player, store }); playerInst = player; } + }, [usedSession.sessionId]); + useEffect(() => { return () => { playerInst?.clean?.(); // @ts-ignore default empty - setContextValue(defaultContextValue); + setContextValue(defaultContextValue) } - }, [usedSession.sessionId]); + }, []) // LAYOUT (TODO: local layout state - useContext or something..) useEffect(() => { @@ -122,5 +125,5 @@ export default withPermissions( userName: state.getIn(['user', 'account', 'name']), }; } - )(withLocationHandlers()(LivePlayer)) + )(withLocationHandlers()(React.memo(LivePlayer))) ) diff --git a/frontend/app/components/Session/LiveSession.js b/frontend/app/components/Session/LiveSession.js index 984d6b1d6..b47527a8d 100644 --- a/frontend/app/components/Session/LiveSession.js +++ b/frontend/app/components/Session/LiveSession.js @@ -78,5 +78,5 @@ export default withPermissions( fetchSession, fetchSlackList, } - )(React.memo(LiveSession)) + )(LiveSession) );