diff --git a/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx b/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx index 18c717cf4..71a117868 100644 --- a/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx +++ b/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx @@ -20,6 +20,9 @@ import ScreenRecorder from 'App/components/Session_/ScreenRecorder/ScreenRecorde function onReject() { toast.info(`Call was rejected.`); } +function onControlReject() { + toast.info('Remote control request was rejected by user') +} function onError(e: any) { console.log(e); @@ -52,6 +55,7 @@ function AssistActions({ setCallArgs, requestReleaseRemoteControl, toggleAnnotation, + setRemoteControlCallbacks }, toggleUserName, } = player @@ -153,6 +157,7 @@ function AssistActions({ }; const requestControl = () => { + setRemoteControlCallbacks({ onReject: onControlReject }) if (callRequesting || remoteRequesting) return; requestReleaseRemoteControl(); }; diff --git a/frontend/app/components/Session_/ScreenRecorder/ScreenRecorder.tsx b/frontend/app/components/Session_/ScreenRecorder/ScreenRecorder.tsx index 4f7d9f0bf..97c3db78d 100644 --- a/frontend/app/components/Session_/ScreenRecorder/ScreenRecorder.tsx +++ b/frontend/app/components/Session_/ScreenRecorder/ScreenRecorder.tsx @@ -100,7 +100,8 @@ function ScreenRecorder({ }; const recordingRequest = () => { - player.assistManager.requestRecording(); + const onDeny = () => toast.info('Recording request was rejected by user') + player.assistManager.requestRecording({ onDeny }); }; if (!isSupported() || !isEnterprise) { diff --git a/frontend/app/player/web/assist/AssistManager.ts b/frontend/app/player/web/assist/AssistManager.ts index 13de4ebdd..e75db1388 100644 --- a/frontend/app/player/web/assist/AssistManager.ts +++ b/frontend/app/player/web/assist/AssistManager.ts @@ -250,6 +250,9 @@ export default class AssistManager { requestReleaseRemoteControl = (...args: Parameters) => { return this.remoteControl?.requestReleaseRemoteControl(...args) } + setRemoteControlCallbacks = (...args: Parameters) => { + return this.remoteControl?.setCallbacks(...args) + } releaseRemoteControl = (...args: Parameters) => { return this.remoteControl?.releaseRemoteControl(...args) } diff --git a/frontend/app/player/web/assist/Call.ts b/frontend/app/player/web/assist/Call.ts index a771794fa..2119b9935 100644 --- a/frontend/app/player/web/assist/Call.ts +++ b/frontend/app/player/web/assist/Call.ts @@ -147,13 +147,11 @@ export default class Call { //this.toggleAnnotation(false) } private onRemoteCallEnd = () => { - if (this.store.get().calling === CallingState.Requesting) { + if ([CallingState.Requesting, CallingState.Connecting].includes(this.store.get().calling)) { this.callArgs && this.callArgs.onReject() this.callConnection[0] && this.callConnection[0].close() this.store.update({ calling: CallingState.NoCall }) this.callArgs = null - // TODO: We have it separated, right? (check) - //this.toggleAnnotation(false) } else { this.handleCallEnd() } diff --git a/frontend/app/player/web/assist/RemoteControl.ts b/frontend/app/player/web/assist/RemoteControl.ts index e262e75b8..56870995d 100644 --- a/frontend/app/player/web/assist/RemoteControl.ts +++ b/frontend/app/player/web/assist/RemoteControl.ts @@ -3,7 +3,6 @@ import type { Socket } from './types' import type Screen from '../Screen/Screen' import type { Store } from '../../common/types' - export enum RemoteControlStatus { Disabled = 0, Requesting, @@ -20,6 +19,7 @@ export default class RemoteControl { remoteControl: RemoteControlStatus.Disabled, annotating: false, } + onReject: () => void = () => {} constructor( private store: Store, @@ -33,6 +33,7 @@ export default class RemoteControl { }) socket.on("control_rejected", id => { id === socket.id && this.toggleRemoteControl(false) + this.onReject() }) socket.on('SESSION_DISCONNECTED', () => { if (this.store.get().remoteControl === RemoteControlStatus.Requesting) { @@ -59,6 +60,10 @@ export default class RemoteControl { this.socket.emit("scroll", [ e.deltaX, e.deltaY ]) } + public setCallbacks = ({ onReject }: { onReject: () => void }) => { + this.onReject = onReject + } + private onMouseClick = (e: MouseEvent): void => { if (this.store.get().annotating) { return; } // ignore clicks while annotating diff --git a/frontend/app/player/web/assist/ScreenRecording.ts b/frontend/app/player/web/assist/ScreenRecording.ts index 90ad76020..933fcc02b 100644 --- a/frontend/app/player/web/assist/ScreenRecording.ts +++ b/frontend/app/player/web/assist/ScreenRecording.ts @@ -15,6 +15,7 @@ export interface State { } export default class ScreenRecording { + onDeny: () => void = () => {} static readonly INITIAL_STATE: Readonly = { recordingState: SessionRecordingStatus.Off, } @@ -29,6 +30,7 @@ export default class ScreenRecording { }) socket.on('recording_rejected', () => { this.toggleRecording(false) + this.onDeny() }) socket.on('recording_busy', () => { this.onRecordingBusy() @@ -39,7 +41,8 @@ export default class ScreenRecording { toast.error("This session is already being recorded by another agent") } - requestRecording = () => { + requestRecording = ({ onDeny }: { onDeny: () => void }) => { + this.onDeny = onDeny const recordingState = this.store.get().recordingState if (recordingState === SessionRecordingStatus.Requesting) return;