Show room broadcast when ending a recording (#9841)
This commit is contained in:
parent
3ce064731b
commit
91e078d96b
4 changed files with 86 additions and 12 deletions
|
@ -24,7 +24,7 @@ export enum VoiceBroadcastRecordingsStoreEvent {
|
|||
}
|
||||
|
||||
interface EventMap {
|
||||
[VoiceBroadcastRecordingsStoreEvent.CurrentChanged]: (recording: VoiceBroadcastRecording) => void;
|
||||
[VoiceBroadcastRecordingsStoreEvent.CurrentChanged]: (recording: VoiceBroadcastRecording | null) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,17 +41,23 @@ export class VoiceBroadcastRecordingsStore extends TypedEventEmitter<VoiceBroadc
|
|||
public setCurrent(current: VoiceBroadcastRecording): void {
|
||||
if (this.current === current) return;
|
||||
|
||||
const infoEventId = current.infoEvent.getId();
|
||||
|
||||
if (!infoEventId) {
|
||||
throw new Error("Got broadcast info event without Id");
|
||||
}
|
||||
|
||||
if (this.current) {
|
||||
this.current.off(VoiceBroadcastRecordingEvent.StateChanged, this.onCurrentStateChanged);
|
||||
}
|
||||
|
||||
this.current = current;
|
||||
this.current.on(VoiceBroadcastRecordingEvent.StateChanged, this.onCurrentStateChanged);
|
||||
this.recordings.set(current.infoEvent.getId(), current);
|
||||
this.recordings.set(infoEventId, current);
|
||||
this.emit(VoiceBroadcastRecordingsStoreEvent.CurrentChanged, current);
|
||||
}
|
||||
|
||||
public getCurrent(): VoiceBroadcastRecording {
|
||||
public getCurrent(): VoiceBroadcastRecording | null {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
|
@ -70,11 +76,13 @@ export class VoiceBroadcastRecordingsStore extends TypedEventEmitter<VoiceBroadc
|
|||
public getByInfoEvent(infoEvent: MatrixEvent, client: MatrixClient): VoiceBroadcastRecording {
|
||||
const infoEventId = infoEvent.getId();
|
||||
|
||||
if (!this.recordings.has(infoEventId)) {
|
||||
this.recordings.set(infoEventId, new VoiceBroadcastRecording(infoEvent, client));
|
||||
if (!infoEventId) {
|
||||
throw new Error("Got broadcast info event without Id");
|
||||
}
|
||||
|
||||
return this.recordings.get(infoEventId);
|
||||
const recording = this.recordings.get(infoEventId) || new VoiceBroadcastRecording(infoEvent, client);
|
||||
this.recordings.set(infoEventId, recording);
|
||||
return recording;
|
||||
}
|
||||
|
||||
private onCurrentStateChanged = (state: VoiceBroadcastInfoState) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue