1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

Use native js-sdk group call support (#9625)

* Use native js-sdk group call support

Now that the js-sdk supports group calls natively, our group call implementation can be simplified a bit. Switching to the js-sdk implementation also brings the react-sdk up to date with recent MSC3401 changes, and adds support for joining calls from multiple devices. (So, the previous logic which sent to-device messages to prevent multi-device sessions is no longer necessary.)

* Fix strings

* Fix strict type errors
This commit is contained in:
Robin
2022-11-28 16:37:32 -05:00
committed by GitHub
parent 3c7781a561
commit 2c612d5aa1
20 changed files with 383 additions and 567 deletions

View File

@@ -16,11 +16,13 @@ limitations under the License.
import { MatrixWidgetType } from "matrix-widget-api";
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
import type { Room } from "matrix-js-sdk/src/models/room";
import type { RoomMember } from "matrix-js-sdk/src/models/room-member";
import type { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { mkEvent } from "./test-utils";
import { Call, ConnectionState, ElementCall, JitsiCall } from "../../src/models/Call";
import { CallStore } from "../../src/stores/CallStore";
export class MockedCall extends Call {
public static readonly EVENT_TYPE = "org.example.mocked_call";
@@ -49,7 +51,6 @@ export class MockedCall extends Call {
}
public static create(room: Room, id: string) {
// Update room state to let CallStore know that a call might now exist
room.addLiveEvents([mkEvent({
event: true,
type: this.EVENT_TYPE,
@@ -59,16 +60,17 @@ export class MockedCall extends Call {
skey: id,
ts: Date.now(),
})]);
// @ts-ignore deliberately calling a private method
// Let CallStore know that a call might now exist
CallStore.instance.updateRoom(room);
}
public get groupCall(): MatrixEvent {
return this.event;
}
public readonly groupCall = { creationTs: this.event.getTs() } as unknown as GroupCall;
public get participants(): Set<RoomMember> {
public get participants(): Map<RoomMember, Set<string>> {
return super.participants;
}
public set participants(value: Set<RoomMember>) {
public set participants(value: Map<RoomMember, Set<string>>) {
super.participants = value;
}
@@ -77,8 +79,7 @@ export class MockedCall extends Call {
}
// No action needed for any of the following methods since this is just a mock
protected getDevices(): string[] { return []; }
protected async setDevices(): Promise<void> { }
public async clean(): Promise<void> {}
// Public to allow spying
public async performConnection(): Promise<void> {}
public async performDisconnection(): Promise<void> {}

View File

@@ -39,6 +39,7 @@ import { ReEmitter } from "matrix-js-sdk/src/ReEmitter";
import { MediaHandler } from "matrix-js-sdk/src/webrtc/mediaHandler";
import { Feature, ServerSupport } from "matrix-js-sdk/src/feature";
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
import { MatrixClientPeg as peg } from '../../src/MatrixClientPeg';
import { makeType } from "../../src/utils/TypeUtils";
import { ValidatedServerConfig } from "../../src/utils/ValidatedServerConfig";
@@ -190,6 +191,7 @@ export function createTestClient(): MatrixClient {
setVideoInput: jest.fn(),
setAudioInput: jest.fn(),
setAudioSettings: jest.fn(),
stopAllStreams: jest.fn(),
} as unknown as MediaHandler),
uploadContent: jest.fn(),
getEventMapper: () => (opts) => new MatrixEvent(opts),
@@ -197,6 +199,7 @@ export function createTestClient(): MatrixClient {
doesServerSupportLogoutDevices: jest.fn().mockReturnValue(true),
requestPasswordEmailToken: jest.fn().mockRejectedValue({}),
setPassword: jest.fn().mockRejectedValue({}),
groupCallEventHandler: { groupCalls: new Map<string, GroupCall>() },
} as unknown as MatrixClient;
client.reEmitter = new ReEmitter(client);
@@ -453,7 +456,7 @@ export function mkStubRoom(roomId: string = null, name: string, client: MatrixCl
getMyMembership: jest.fn().mockReturnValue("join"),
maySendMessage: jest.fn().mockReturnValue(true),
currentState: {
getStateEvents: jest.fn(),
getStateEvents: jest.fn((_type, key) => key === undefined ? [] : null),
getMember: jest.fn(),
mayClientSendStateEvent: jest.fn().mockReturnValue(true),
maySendStateEvent: jest.fn().mockReturnValue(true),