End voice broadcast recording on any call (#9425)
This commit is contained in:
parent
81533b905f
commit
0630a9c448
4 changed files with 78 additions and 4 deletions
|
@ -65,6 +65,7 @@ import { arrayFastClone } from "../../utils/arrays";
|
|||
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
import Modal from "../../Modal";
|
||||
import ErrorDialog from "../../components/views/dialogs/ErrorDialog";
|
||||
import { VoiceBroadcastRecordingsStore } from "../../voice-broadcast";
|
||||
|
||||
// TODO: Destroy all of this code
|
||||
|
||||
|
@ -280,6 +281,10 @@ export class StopGapWidget extends EventEmitter {
|
|||
});
|
||||
this.messaging.on("capabilitiesNotified", () => this.emit("capabilitiesNotified"));
|
||||
this.messaging.on(`action:${WidgetApiFromWidgetAction.OpenModalWidget}`, this.onOpenModal);
|
||||
this.messaging.on(`action:${ElementWidgetActions.JoinCall}`, () => {
|
||||
// stop voice broadcast recording when any widget sends a "join"
|
||||
VoiceBroadcastRecordingsStore.instance().getCurrent()?.stop();
|
||||
});
|
||||
|
||||
// Always attach a handler for ViewRoom, but permission check it internally
|
||||
this.messaging.on(`action:${ElementWidgetActions.ViewRoom}`, (ev: CustomEvent<IViewRoomApiRequest>) => {
|
||||
|
|
|
@ -30,6 +30,8 @@ import { uploadFile } from "../../ContentMessages";
|
|||
import { IEncryptedFile } from "../../customisations/models/IMediaEventContent";
|
||||
import { createVoiceMessageContent } from "../../utils/createVoiceMessageContent";
|
||||
import { IDestroyable } from "../../utils/IDestroyable";
|
||||
import dis from "../../dispatcher/dispatcher";
|
||||
import { ActionPayload } from "../../dispatcher/payloads";
|
||||
|
||||
export enum VoiceBroadcastRecordingEvent {
|
||||
StateChanged = "liveness_changed",
|
||||
|
@ -45,6 +47,7 @@ export class VoiceBroadcastRecording
|
|||
private state: VoiceBroadcastInfoState;
|
||||
private recorder: VoiceBroadcastRecorder;
|
||||
private sequence = 1;
|
||||
private dispatcherRef: string;
|
||||
|
||||
public constructor(
|
||||
public readonly infoEvent: MatrixEvent,
|
||||
|
@ -62,8 +65,9 @@ export class VoiceBroadcastRecording
|
|||
this.state = !relatedEvents?.find((event: MatrixEvent) => {
|
||||
return event.getContent()?.state === VoiceBroadcastInfoState.Stopped;
|
||||
}) ? VoiceBroadcastInfoState.Started : VoiceBroadcastInfoState.Stopped;
|
||||
|
||||
// TODO Michael W: add listening for updates
|
||||
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
}
|
||||
|
||||
public async start(): Promise<void> {
|
||||
|
@ -96,8 +100,16 @@ export class VoiceBroadcastRecording
|
|||
}
|
||||
|
||||
this.removeAllListeners();
|
||||
dis.unregister(this.dispatcherRef);
|
||||
}
|
||||
|
||||
private onAction = (payload: ActionPayload) => {
|
||||
if (payload.action !== "call_state") return;
|
||||
|
||||
// stop on any call action
|
||||
this.stop();
|
||||
};
|
||||
|
||||
private setState(state: VoiceBroadcastInfoState): void {
|
||||
this.state = state;
|
||||
this.emit(VoiceBroadcastRecordingEvent.StateChanged, this.state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue