Show voice room participants when not connected (#8136)

* Add utility for getting connected voice participants

* Allow voice room members to send connected device state

* Update connected devices when connecting/disconnecting voice

* Show voice room participants in room tile when not connected

* Update voice room tests

* Add null types and guards
This commit is contained in:
Robin 2022-03-28 09:12:09 -04:00 committed by GitHub
parent 0a16989d26
commit 8baf06c3ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 378 additions and 143 deletions

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { EventEmitter } from "events";
import React from "react";
import { mount } from "enzyme";
import { act } from "react-dom/test-utils";
@ -22,49 +21,14 @@ import { mocked } from "jest-mock";
import "../../../skinned-sdk";
import { stubClient, mkStubRoom, wrapInMatrixClientContext } from "../../../test-utils";
import { stubVoiceChannelStore } from "../../../test-utils/voice";
import _VoiceChannelRadio from "../../../../src/components/views/voip/VoiceChannelRadio";
import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/VoiceChannelStore";
import VoiceChannelStore from "../../../../src/stores/VoiceChannelStore";
import DMRoomMap from "../../../../src/utils/DMRoomMap";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
const VoiceChannelRadio = wrapInMatrixClientContext(_VoiceChannelRadio);
class StubVoiceChannelStore extends EventEmitter {
private _roomId: string;
public get roomId(): string { return this._roomId; }
private _audioMuted: boolean;
public get audioMuted(): boolean { return this._audioMuted; }
private _videoMuted: boolean;
public get videoMuted(): boolean { return this._videoMuted; }
public connect = jest.fn().mockImplementation(async (roomId: string) => {
this._roomId = roomId;
this._audioMuted = true;
this._videoMuted = true;
this.emit(VoiceChannelEvent.Connect);
});
public disconnect = jest.fn().mockImplementation(async () => {
this._roomId = null;
this.emit(VoiceChannelEvent.Disconnect);
});
public muteAudio = jest.fn().mockImplementation(async () => {
this._audioMuted = true;
this.emit(VoiceChannelEvent.MuteAudio);
});
public unmuteAudio = jest.fn().mockImplementation(async () => {
this._audioMuted = false;
this.emit(VoiceChannelEvent.UnmuteAudio);
});
public muteVideo = jest.fn().mockImplementation(async () => {
this._videoMuted = true;
this.emit(VoiceChannelEvent.MuteVideo);
});
public unmuteVideo = jest.fn().mockImplementation(async () => {
this._videoMuted = false;
this.emit(VoiceChannelEvent.UnmuteVideo);
});
}
describe("VoiceChannelRadio", () => {
const cli = mocked(MatrixClientPeg.get());
const room = mkStubRoom("!1:example.org", "voice channel", cli);
@ -72,10 +36,8 @@ describe("VoiceChannelRadio", () => {
beforeEach(() => {
stubClient();
stubVoiceChannelStore();
DMRoomMap.makeShared();
// Stub out the VoiceChannelStore
jest.spyOn(VoiceChannelStore, "instance", "get")
.mockReturnValue(new StubVoiceChannelStore() as unknown as VoiceChannelStore);
});
it("shows when connecting voice", async () => {