Resume voice broadcast on load (#9475)

This commit is contained in:
Michael Weimann 2022-10-21 09:30:02 +02:00 committed by GitHub
parent 493ee425b7
commit 5f59ce182e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 554 additions and 22 deletions

View file

@ -52,9 +52,23 @@ export class VoiceBroadcastRecording
public constructor(
public readonly infoEvent: MatrixEvent,
private client: MatrixClient,
initialState?: VoiceBroadcastInfoState,
) {
super();
if (initialState) {
this.state = initialState;
} else {
this.setInitialStateFromInfoEvent();
}
// TODO Michael W: listen for state updates
//
this.infoEvent.on(MatrixEventEvent.BeforeRedaction, this.onBeforeRedaction);
this.dispatcherRef = dis.register(this.onAction);
}
private setInitialStateFromInfoEvent(): void {
const room = this.client.getRoom(this.infoEvent.getRoomId());
const relations = room?.getUnfilteredTimelineSet()?.relations?.getChildEventsForEvent(
this.infoEvent.getId(),
@ -65,10 +79,6 @@ 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.infoEvent.on(MatrixEventEvent.BeforeRedaction, this.onBeforeRedaction);
this.dispatcherRef = dis.register(this.onAction);
}
public async start(): Promise<void> {