change(ui): signal reject event for call, recording and control
This commit is contained in:
parent
c313119363
commit
0516d58632
6 changed files with 21 additions and 6 deletions
|
|
@ -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();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -250,6 +250,9 @@ export default class AssistManager {
|
|||
requestReleaseRemoteControl = (...args: Parameters<RemoteControl['requestReleaseRemoteControl']>) => {
|
||||
return this.remoteControl?.requestReleaseRemoteControl(...args)
|
||||
}
|
||||
setRemoteControlCallbacks = (...args: Parameters<RemoteControl['setCallbacks']>) => {
|
||||
return this.remoteControl?.setCallbacks(...args)
|
||||
}
|
||||
releaseRemoteControl = (...args: Parameters<RemoteControl['releaseRemoteControl']>) => {
|
||||
return this.remoteControl?.releaseRemoteControl(...args)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<State>,
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export interface State {
|
|||
}
|
||||
|
||||
export default class ScreenRecording {
|
||||
onDeny: () => void = () => {}
|
||||
static readonly INITIAL_STATE: Readonly<State> = {
|
||||
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue