fix assist cleanup (#1111)

* change(player): cleanup assist sockets on unmount

* change(player): remove memo

* change(player): fix unmount?
This commit is contained in:
Delirium 2023-04-05 18:10:34 +02:00 committed by GitHub
parent 83112fc768
commit 8d34afebc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -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)))
)

View file

@ -78,5 +78,5 @@ export default withPermissions(
fetchSession,
fetchSlackList,
}
)(React.memo(LiveSession))
)(LiveSession)
);