change(player): fix player unmount (#1112)
This commit is contained in:
parent
8d34afebc4
commit
68fe2c722c
1 changed files with 6 additions and 7 deletions
|
|
@ -34,15 +34,17 @@ function WebPlayer(props: any) {
|
|||
const [visuallyAdjusted, setAdjusted] = useState(false);
|
||||
// @ts-ignore
|
||||
const [contextValue, setContextValue] = useState<IPlayerContext>(defaultContextValue);
|
||||
let playerInst: IPlayerContext['player'];
|
||||
|
||||
useEffect(() => {
|
||||
if (!session.sessionId) return;
|
||||
if (!session.sessionId || contextValue.player !== undefined) return;
|
||||
fetchList('issues');
|
||||
|
||||
const [WebPlayerInst, PlayerStore] = createWebPlayer(session, (state) =>
|
||||
makeAutoObservable(state)
|
||||
);
|
||||
setContextValue({ player: WebPlayerInst, store: PlayerStore });
|
||||
playerInst = WebPlayerInst;
|
||||
|
||||
notesStore.fetchSessionNotes(session.sessionId).then((r) => {
|
||||
const note = props.query.get('note');
|
||||
|
|
@ -61,12 +63,6 @@ function WebPlayer(props: any) {
|
|||
if (freeze) {
|
||||
WebPlayerInst.freeze()
|
||||
}
|
||||
|
||||
return () => {
|
||||
WebPlayerInst.clean();
|
||||
// @ts-ignore
|
||||
setContextValue(defaultContextValue);
|
||||
}
|
||||
}, [session.sessionId]);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
|
@ -97,6 +93,9 @@ function WebPlayer(props: any) {
|
|||
() => () => {
|
||||
toggleFullscreen(false);
|
||||
closeBottomBlock();
|
||||
playerInst?.clean();
|
||||
// @ts-ignore
|
||||
setContextValue(defaultContextValue);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue