Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Replace voice broadcast running with resumed (#9502)
Browse files Browse the repository at this point in the history
  • Loading branch information
weeman1337 authored Oct 26, 2022
1 parent 238a2b7 commit 625971a
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/voice-broadcast/hooks/useVoiceBroadcastRecording.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const useVoiceBroadcastRecording = (recording: VoiceBroadcastRecording) =
const live = [
VoiceBroadcastInfoState.Started,
VoiceBroadcastInfoState.Paused,
VoiceBroadcastInfoState.Running,
VoiceBroadcastInfoState.Resumed,
].includes(recordingState);

return {
Expand Down
2 changes: 1 addition & 1 deletion src/voice-broadcast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const VoiceBroadcastChunkEventType = "io.element.voice_broadcast_chunk";
export enum VoiceBroadcastInfoState {
Started = "started",
Paused = "paused",
Running = "running",
Resumed = "resumed",
Stopped = "stopped",
}

Expand Down
6 changes: 3 additions & 3 deletions src/voice-broadcast/models/VoiceBroadcastRecording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ export class VoiceBroadcastRecording
public async resume(): Promise<void> {
if (this.state !== VoiceBroadcastInfoState.Paused) return;

this.setState(VoiceBroadcastInfoState.Running);
this.setState(VoiceBroadcastInfoState.Resumed);
await this.getRecorder().start();
await this.sendInfoStateEvent(VoiceBroadcastInfoState.Running);
await this.sendInfoStateEvent(VoiceBroadcastInfoState.Resumed);
}

public toggle = async (): Promise<void> => {
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();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("VoiceBroadcastRecordingBody", () => {
room: roomId,
user: userId,
});
recording = new VoiceBroadcastRecording(infoEvent, client, VoiceBroadcastInfoState.Running);
recording = new VoiceBroadcastRecording(infoEvent, client, VoiceBroadcastInfoState.Resumed);
});

describe("when rendering a live broadcast", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("VoiceBroadcastRecordingPip", () => {
});

it("should resume the recording", () => {
expect(recording.getState()).toBe(VoiceBroadcastInfoState.Running);
expect(recording.getState()).toBe(VoiceBroadcastInfoState.Resumed);
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions test/voice-broadcast/models/VoiceBroadcastPlayback-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ describe("VoiceBroadcastPlayback", () => {
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(() => {
infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Running);
infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Resumed);
playback = mkPlayback();
setUpChunkEvents([]);
});
Expand Down Expand Up @@ -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(() => {
infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Running);
infoEvent = mkInfoEvent(VoiceBroadcastInfoState.Resumed);
playback = mkPlayback();
setUpChunkEvents([chunk2Event, chunk0Event, chunk1Event]);
});
Expand Down
8 changes: 4 additions & 4 deletions test/voice-broadcast/models/VoiceBroadcastRecording-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,15 @@ describe("VoiceBroadcastRecording", () => {
await action();
});

itShouldBeInState(VoiceBroadcastInfoState.Running);
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Running);
itShouldBeInState(VoiceBroadcastInfoState.Resumed);
itShouldSendAnInfoEvent(VoiceBroadcastInfoState.Resumed);

it("should start the recorder", () => {
expect(mocked(voiceBroadcastRecorder.start)).toHaveBeenCalled();
});

it("should emit a running state changed event", () => {
expect(onStateChanged).toHaveBeenCalledWith(VoiceBroadcastInfoState.Running);
it(`should emit a ${VoiceBroadcastInfoState.Resumed} state changed event`, () => {
expect(onStateChanged).toHaveBeenCalledWith(VoiceBroadcastInfoState.Resumed);
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/voice-broadcast/utils/hasRoomLiveVoiceBroadcast-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("hasRoomLiveVoiceBroadcast", () => {
// all there are kind of live states
VoiceBroadcastInfoState.Started,
VoiceBroadcastInfoState.Paused,
VoiceBroadcastInfoState.Running,
VoiceBroadcastInfoState.Resumed,
])("when there is a live broadcast (%s) from the current user", (state: VoiceBroadcastInfoState) => {
beforeEach(() => {
addVoiceBroadcastInfoEvent(state, client.getUserId());
Expand All @@ -132,7 +132,7 @@ describe("hasRoomLiveVoiceBroadcast", () => {

describe("when there was a live broadcast, that has been stopped", () => {
beforeEach(() => {
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Running, client.getUserId());
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Resumed, client.getUserId());
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Stopped, client.getUserId());
});

Expand All @@ -141,7 +141,7 @@ describe("hasRoomLiveVoiceBroadcast", () => {

describe("when there is a live broadcast from another user", () => {
beforeEach(() => {
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Running, otherUserId);
addVoiceBroadcastInfoEvent(VoiceBroadcastInfoState.Resumed, otherUserId);
});

itShouldReturnTrueFalse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const testCases = [
[
"@user1:example.com",
"@user1:example.com",
VoiceBroadcastInfoState.Running,
VoiceBroadcastInfoState.Resumed,
true,
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe("shouldDisplayAsVoiceBroadcastTile", () => {
describe.each(
[
VoiceBroadcastInfoState.Paused,
VoiceBroadcastInfoState.Running,
VoiceBroadcastInfoState.Resumed,
VoiceBroadcastInfoState.Stopped,
],
)("when a voice broadcast info event in state %s occurs", (state: VoiceBroadcastInfoState) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe("startNewVoiceBroadcastRecording", () => {
room.currentState.setStateEvents([
mkVoiceBroadcastInfoStateEvent(
roomId,
VoiceBroadcastInfoState.Running,
VoiceBroadcastInfoState.Resumed,
client.getUserId(),
client.getDeviceId(),
),
Expand All @@ -184,7 +184,7 @@ describe("startNewVoiceBroadcastRecording", () => {
room.currentState.setStateEvents([
mkVoiceBroadcastInfoStateEvent(
roomId,
VoiceBroadcastInfoState.Running,
VoiceBroadcastInfoState.Resumed,
otherUserId,
"ASD123",
),
Expand Down

0 comments on commit 625971a

Please sign in to comment.