fix(ui): fix player destruction on id change (#1145)

Co-authored-by: nick-delirium <nikita@openreplay.com>
This commit is contained in:
Shekar Siri 2023-04-11 12:13:52 +02:00 committed by GitHub
parent 28a1ccf63e
commit 6993104a02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,7 @@ import PlayerContent from './Player/ReplayPlayer/PlayerContent';
import { IPlayerContext, PlayerContext, defaultContextValue } from './playerContext';
import { observer } from 'mobx-react-lite';
import { Note } from "App/services/NotesService";
import { useParams } from 'react-router-dom'
const TABS = {
EVENTS: 'User Steps',
@ -35,6 +36,7 @@ function WebPlayer(props: any) {
// @ts-ignore
const [contextValue, setContextValue] = useState<IPlayerContext>(defaultContextValue);
let playerInst: IPlayerContext['player'];
const params: { sessionId: string } = useParams()
useEffect(() => {
if (!session.sessionId || contextValue.player !== undefined) return;
@ -91,13 +93,14 @@ function WebPlayer(props: any) {
// LAYOUT (TODO: local layout state - useContext or something..)
useEffect(
() => () => {
console.debug('cleaning up player after', params.sessionId)
toggleFullscreen(false);
closeBottomBlock();
playerInst?.clean();
// @ts-ignore
setContextValue(defaultContextValue);
},
[]
[params.sessionId]
);
const onNoteClose = () => {