diff --git a/frontend/app/player/MessageDistributor/MessageDistributor.ts b/frontend/app/player/MessageDistributor/MessageDistributor.ts index fe95b9291..a51430b41 100644 --- a/frontend/app/player/MessageDistributor/MessageDistributor.ts +++ b/frontend/app/player/MessageDistributor/MessageDistributor.ts @@ -28,6 +28,7 @@ import AssistManager from './managers/AssistManager'; import MessageReader from './MessageReader'; import { INITIAL_STATE as PARENT_INITIAL_STATE } from './StatedScreen'; +import { INITIAL_STATE as ASSIST_INITIAL_STATE } from './managers/AssistManager'; import type { TimedMessage } from './Timed'; @@ -40,6 +41,7 @@ LIST_NAMES.forEach(name => { export const INITIAL_STATE = { ...PARENT_INITIAL_STATE, ...LISTS_INITIAL_STATE, + ...ASSIST_INITIAL_STATE, performanceChartData: [], skipIntervals: [], } as const; diff --git a/frontend/app/player/MessageDistributor/managers/AssistManager.ts b/frontend/app/player/MessageDistributor/managers/AssistManager.ts index 2c401e298..6affb05dd 100644 --- a/frontend/app/player/MessageDistributor/managers/AssistManager.ts +++ b/frontend/app/player/MessageDistributor/managers/AssistManager.ts @@ -5,6 +5,12 @@ import type { TimedMessage } from '../Timed'; import type { Message } from '../messages' import { ID_TP_MAP } from '../messages'; +import { update, getState } from '../../store'; + + +export const INITIAL_STATE = { + calling: false; +} export default class AssistManager { @@ -117,14 +123,13 @@ export default class AssistManager { conn.send({ x: Math.round(data.x), y: Math.round(data.y) }); // debounce? } - private calling: boolean = false; call(localStream: MediaStream, onStream: (s: MediaStream)=>void, onClose: () => void, onError?: ()=> void): null | Function { - if (!this.peer || this.calling) { return null; } + if (!this.peer || getState().calling) { return null; } const call = this.peer.call(this.peerID, localStream); console.log('calling...') - this.calling = true; + update({ calling: true}); call.on('stream', stream => { onStream(stream); // @ts-ignore ?? @@ -134,7 +139,7 @@ export default class AssistManager { this.onCallEnd = () => { // @ts-ignore ?? this.md.overlay.removeEventListener("mousemove", this.onMouseMoveShare); - this.calling = false; + update({ calling: false}); onClose(); } call.on("close", this.onCallEnd);