Replace voice broadcast running with resumed (#9502)

This commit is contained in:
Michael Weimann 2022-10-26 14:54:44 +02:00 committed by GitHub
parent 238a2b77af
commit 625971acb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 22 additions and 22 deletions

View file

@ -68,7 +68,7 @@ export const useVoiceBroadcastRecording = (recording: VoiceBroadcastRecording) =
const live = [ const live = [
VoiceBroadcastInfoState.Started, VoiceBroadcastInfoState.Started,
VoiceBroadcastInfoState.Paused, VoiceBroadcastInfoState.Paused,
VoiceBroadcastInfoState.Running, VoiceBroadcastInfoState.Resumed,
].includes(recordingState); ].includes(recordingState);
return { return {

View file

@ -49,7 +49,7 @@ export const VoiceBroadcastChunkEventType = "io.element.voice_broadcast_chunk";
export enum VoiceBroadcastInfoState { export enum VoiceBroadcastInfoState {
Started = "started", Started = "started",
Paused = "paused", Paused = "paused",
Running = "running", Resumed = "resumed",
Stopped = "stopped", Stopped = "stopped",
} }

View file

@ -105,15 +105,15 @@ export class VoiceBroadcastRecording
public async resume(): Promise<void> { public async resume(): Promise<void> {
if (this.state !== VoiceBroadcastInfoState.Paused) return; if (this.state !== VoiceBroadcastInfoState.Paused) return;
this.setState(VoiceBroadcastInfoState.Running); this.setState(VoiceBroadcastInfoState.Resumed);
await this.getRecorder().start(); await this.getRecorder().start();
await this.sendInfoStateEvent(VoiceBroadcastInfoState.Running); await this.sendInfoStateEvent(VoiceBroadcastInfoState.Resumed);
} }
public toggle = async (): Promise<void> => { public toggle = async (): Promise<void> => {
if (this.getState() === VoiceBroadcastInfoState.Paused) return this.resume(); if (this.getState() === VoiceBroadcastInfoState.Paused) return this.resume();
if ([VoiceBroadcastInfoState.Started, VoiceBroadcastInfoState.Running].includes(this.getState())) { if ([VoiceBroadcastInfoState.Started, VoiceBroadcastInfoState.Resumed].includes(this.getState())) {
return this.pause(); return this.pause();
} }
}; };

View file

@ -50,7 +50,7 @@ describe("VoiceBroadcastRecordingBody", () => {
room: roomId, room: roomId,
user: userId, user: userId,
}); });
recording = new VoiceBroadcastRecording(infoEvent, client, VoiceBroadcastInfoState.Running); recording = new VoiceBroadcastRecording(infoEvent, client, VoiceBroadcastInfoState.Resumed);
}); });
describe("when rendering a live broadcast", () => { describe("when rendering a live broadcast", () => {

View file

@ -118,7 +118,7 @@ describe("VoiceBroadcastRecordingPip", () => {
}); });
it("should resume the recording", () => { it("should resume the recording", () => {
expect(recording.getState()).toBe(VoiceBroadcastInfoState.Running); expect(recording.getState()).toBe(VoiceBroadcastInfoState.Resumed);
}); });
}); });
}); });

View file

@ -190,9 +190,9 @@ describe("VoiceBroadcastPlayback", () => {
onStateChanged = jest.fn(); onStateChanged = jest.fn();
}); });
describe("when there is a running broadcast without chunks yet", () => { describe(`when there is a ${VoiceBroadcastInfoState.Resumed} broadcast without chunks yet`, () => {
beforeEach(() => { beforeEach(() => {
infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Running); infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Resumed);
playback = mkPlayback(); playback = mkPlayback();
setUpChunkEvents([]); setUpChunkEvents([]);
}); });
@ -236,9 +236,9 @@ describe("VoiceBroadcastPlayback", () => {
}); });
}); });
describe("when there is a running voice broadcast with some chunks", () => { describe(`when there is a ${VoiceBroadcastInfoState.Resumed} voice broadcast with some chunks`, () => {
beforeEach(() => { beforeEach(() => {
infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Running); infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Resumed);
playback = mkPlayback(); playback = mkPlayback();
setUpChunkEvents([chunk2Event, chunk0Event, chunk1Event]); setUpChunkEvents([chunk2Event, chunk0Event, chunk1Event]);
}); });

View file

@ -423,15 +423,15 @@ describe("VoiceBroadcastRecording", () => {
await action(); await action();
}); });
itShouldBeInState(VoiceBroadcastInfoState.Running); itShouldBeInState(VoiceBroadcastInfoState.Resumed);
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Running); itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Resumed);
it("should start the recorder", () => { it("should start the recorder", () => {
expect(mocked(voiceBroadcastRecorder.start)).toHaveBeenCalled(); expect(mocked(voiceBroadcastRecorder.start)).toHaveBeenCalled();
}); });
it("should emit a running state changed event", () => { it(`should emit a ${VoiceBroadcastInfoState.Resumed} state changed event`, () => {
expect(onStateChanged).toHaveBeenCalledWith(VoiceBroadcastInfoState.Running); expect(onStateChanged).toHaveBeenCalledWith(VoiceBroadcastInfoState.Resumed);
}); });
}); });
}); });

View file

@ -121,7 +121,7 @@ describe("hasRoomLiveVoiceBroadcast", () => {
// all there are kind of live states // all there are kind of live states
VoiceBroadcastInfoState.Started, VoiceBroadcastInfoState.Started,
VoiceBroadcastInfoState.Paused, VoiceBroadcastInfoState.Paused,
VoiceBroadcastInfoState.Running, VoiceBroadcastInfoState.Resumed,
])("when there is a live broadcast (%s) from the current user", (state: VoiceBroadcastInfoState) => { ])("when there is a live broadcast (%s) from the current user", (state: VoiceBroadcastInfoState) => {
beforeEach(() => { beforeEach(() => {
addVoiceBroadcastInfoEvent(state, client.getUserId()); addVoiceBroadcastInfoEvent(state, client.getUserId());
@ -132,7 +132,7 @@ describe("hasRoomLiveVoiceBroadcast", () => {
describe("when there was a live broadcast, that has been stopped", () => { describe("when there was a live broadcast, that has been stopped", () => {
beforeEach(() => { beforeEach(() => {
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Running, client.getUserId()); addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Resumed, client.getUserId());
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Stopped, client.getUserId()); addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Stopped, client.getUserId());
}); });
@ -141,7 +141,7 @@ describe("hasRoomLiveVoiceBroadcast", () => {
describe("when there is a live broadcast from another user", () => { describe("when there is a live broadcast from another user", () => {
beforeEach(() => { beforeEach(() => {
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Running, otherUserId); addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Resumed, otherUserId);
}); });
itShouldReturnTrueFalse(); itShouldReturnTrueFalse();

View file

@ -40,7 +40,7 @@ const testCases = [
[ [
"@user1:example.com", "@user1:example.com",
"@user1:example.com", "@user1:example.com",
VoiceBroadcastInfoState.Running, VoiceBroadcastInfoState.Resumed,
true, true,
], ],
[ [

View file

@ -128,7 +128,7 @@ describe("shouldDisplayAsVoiceBroadcastTile", () => {
describe.each( describe.each(
[ [
VoiceBroadcastInfoState.Paused, VoiceBroadcastInfoState.Paused,
VoiceBroadcastInfoState.Running, VoiceBroadcastInfoState.Resumed,
VoiceBroadcastInfoState.Stopped, VoiceBroadcastInfoState.Stopped,
], ],
)("when a voice broadcast info event in state %s occurs", (state: VoiceBroadcastInfoState) => { )("when a voice broadcast info event in state %s occurs", (state: VoiceBroadcastInfoState) => {

View file

@ -161,7 +161,7 @@ describe("startNewVoiceBroadcastRecording", () => {
room.currentState.setStateEvents([ room.currentState.setStateEvents([
mkVoiceBroadcastInfoStateEvent( mkVoiceBroadcastInfoStateEvent(
roomId, roomId,
VoiceBroadcastInfoState.Running, VoiceBroadcastInfoState.Resumed,
client.getUserId(), client.getUserId(),
client.getDeviceId(), client.getDeviceId(),
), ),
@ -184,7 +184,7 @@ describe("startNewVoiceBroadcastRecording", () => {
room.currentState.setStateEvents([ room.currentState.setStateEvents([
mkVoiceBroadcastInfoStateEvent( mkVoiceBroadcastInfoStateEvent(
roomId, roomId,
VoiceBroadcastInfoState.Running, VoiceBroadcastInfoState.Resumed,
otherUserId, otherUserId,
"ASD123", "ASD123",
), ),